#课堂笔记
把Python的对象转化为二进制的形式存放,这个过程称为pickling
把二进制形式转化回对象称为unpickling
For example:
#保存列表
import pickle
my_list = [3,3.14,"lizi",["love"]]
pickle_file = open("my_list.pkl","wb")
pickle.dump(my_list,pickle_file)
pickle_file.close()
#打开文件
pickle_file=open("my_list.pkl","rb")
my_list = pickle.load(pickle_file)
print(my_list)
pickle_file.close()