python 学习第四十七天shelve模块
生活随笔
收集整理的這篇文章主要介紹了
python 学习第四十七天shelve模块
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
? ? shelve模塊是一個(gè)簡(jiǎn)單的k,v將內(nèi)存數(shù)據(jù)通過文件持久化的模塊,可以持久化任何pickle可支持的python數(shù)據(jù)格式。
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']
就是將序列持久存在一個(gè)文件中。
轉(zhuǎn)載于:https://www.cnblogs.com/96net/p/9769196.html
總結(jié)
以上是生活随笔為你收集整理的python 学习第四十七天shelve模块的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MacOS下安装BeautifulSou
- 下一篇: 深入理解L1、L2正则化