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
- 下一篇: 深入理解L1、L2正则化