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)

posted on 2017-09-14 15:25  sammy1989  阅读(168)  评论(0编辑  收藏  举报

导航