标签:
pickle是一个可以将任意一个对象存储在硬盘文件中的工具。
ref:https://docs.python.org/2/library/pickle.html
常用的用法就两个。。。dump(写入文件)和load(从文件中读)
demo:
1 __author__ = ‘IBM‘ 2 import cPickle as pickle 3 4 fp="D:/pycharmprojects/pickle_demo/r.pkl" 5 6 data="233333_woshihanbazi" 7 with open(fp,"w") as f: 8 pickle.dump(data,f) 9 10 with open(fp,"r") as f: 11 dat=pickle.load(f) 12 print(dat)
Output:
233333_woshihanbazi
标签:
原文地址:http://www.cnblogs.com/pdev/p/5185969.html