import pickle
Save the object to a file
mydict = {1: 'Pochi',
2: 'Taro',
3: 'Jiro'}
with open('xxx.dump', 'w') as f:
pickle.dump(mydict, f)
Read an object from a file
with open('xxx.dump', 'r') as f:
mydict_load = pickle.load(f)
print mydict_load # {1: 'Pochi', 2: 'Taro', 3: 'Jiro'}
Recommended Posts