write Python dict (mb with unicode) to a file

Matt Nordhoff mnordhoff at mattnordhoff.com
Sat Jun 14 11:59:55 CEST 2008


dmitrey wrote:
> hi all,
> what's the best way to write Python dictionary to a file?
> 
> (and then read)
> 
> There could be unicode field names and values encountered.
> Thank you in advance, D.

pickle/cPickle, perhaps, if you're willing to trust the file (since it's
basically eval()ed)? Or JSON (use simplejson or the enhanced version of
cjson), though I doubt it would be super-fast.
-- 



More information about the Python-list mailing list