import pickle
sample_dic = {'key1': 1, 'key2': 2, 'key3': 3}
sample_dic['key4'] = 4
f = open('sample.binaryfile','wb')
pickle.dump(sample_dic,f)
f.close
f = open('sample.binaryfile','rb')
new_dic = pickle.load(f)
print(new_dic)
print(new_dic['key4'])
Recommended Posts