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'])
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme