python 学习第四十七天shelve模块
生活随笔
收集整理的这篇文章主要介绍了
python 学习第四十七天shelve模块
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
shelve模块是一个简单的k,v将内存数据通过文件持久化的模块,可以持久化任何pickle可支持的python数据格式。
1,序列化
import shelve
f=shelve.open('shelve_test')
names=['www.96net.com.cn',"www.dc3688.com","www.baidu.com"]
info=['name','woodson','age':22]
f["names"]=names
f['info_other']=info
f.close()
2,反序列化
import shelve
d=shelve.open('shelve_test')
print(d['name'])
删除 d['info_other']
就是将序列持久存在一个文件中。
转载于:https://www.cnblogs.com/96net/p/9769196.html
总结
以上是生活随笔为你收集整理的python 学习第四十七天shelve模块的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: MacOS下安装BeautifulSou
- 下一篇: 【python】BytesIO与串化