python3“腌制”数据
import pickle
'''必须以二进制模式打开文件'''
with open('mydata.pickle', 'wb') as mysavedata:
'''使用dump()保存数据'''
pickle.dump([1, 2, 'three'], mysavedata)
with open('mydata.pickle', 'rb') as myrestoredata:
'''使用load()恢复数据'''
a_list = pickle.load(myrestoredata)
print(a_list)