Help on dictionaries...

MRAB python at mrabarnett.plus.com
Wed Jan 29 22:13:26 EST 2020


On 2020-01-30 01:51, Michael Torrie wrote:
> On 1/29/20 6:14 PM, Souvik Dutta wrote:
>> Hey I was thinking how I can save a dictionary in python(obviously) so that
>> the script is rerun it automatically loads the dictionary.
> 
> You could use the pickle module for that. See the python.org
> documentation on pickle.
> 
> Alternatively you could use a json library to write the dict to disk.  I
> think this might be preferable to pickle in many situations.
> 
> Or serialize the data yourself to a file.
> 
JSON itself supports only a limited range of types, so additional work 
is needed, especially when loading, if the dict contains any other types 
beyond those.


More information about the Python-list mailing list