标签:htm .com target com time now() pen www. 数据格式
shelve模块是一个简单的k,v将内存数据通过文件持久化的模块,可以持久化任何pickle可支持的python数据格式
import shelve
import datetime
d = shelve.open(‘shelve_test‘) # 打开一个文件
print(d.get("name"))
print(d.get("info"))
print(d.get("date"))
#
‘‘‘
info = {‘age‘:22,"job":‘it‘}
name = ["alex", "rain", "test"]
d["name"] = name # 持久化列表
d["info"] = info # 持久dict
d[‘date‘] = datetime.datetime.now()
d.close()
‘‘‘
相关链接:http://www.cnblogs.com/alex3714/articles/5161349.html
标签:htm .com target com time now() pen www. 数据格式
原文地址:https://www.cnblogs.com/rongye/p/9942495.html