本文主要是介绍python pickle模块(数据持久存储),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
存放:pickling
读取:unpickling
示例:
>>> my_list = ['ddd',564,'TG',['1523','rww']]
>>> pickle_file = open('my_list.pkl','wb')
>>> pickle.dump(my_list,pickle_file)
>>> pickle_file.close()
>>>
>>>
>>>
>>> pickle_file=open('my_list.pkl','rb')
>>> my_list2 = pickle.load(pickle_file)
>>> print(my_list2)
['ddd', 564, 'TG', ['1523', 'rww']]
>>>
这篇关于python pickle模块(数据持久存储)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!