示例:
def test():
return 1
import pickle
# import cPickle as pickle #C开发的pickle,速度更快
a = test
b = {'a':'b'}
with open('text.txt','wb') as file:
pickle.dump(a,file)
pickle.dump(b,file)
with open('text.txt','rb') as file2:
#会按顺序重新load出来
c = pickle.load(file2)
d = pickle.load(file2)
print(c())
print(d)
Ref:https://www.zhihu.com/question/38355589
http://python.jobbole.com/85771/
http://python.jobbole.com/85772/