python对象的序列化与反序列化(对象流)

#对象读写,pickle模块实现了基本的数据序列与反序列化

#1.对象序列化
import pickle
li = ['one','two','three']
with open('serialize.txt','wb') as f:
    pickle.dump(li,f)

#2.对象反序列化
with open('serialize.txt','rb') as f:
    li = pickle.load(f)
    print(li)

 

你可能感兴趣的:(python)