标签:txt imp shelve 说明 import port get 方式 inf
一种字典形式储存数据的方式
import datetime, shelve
d = shelve.open(‘shelve_test.txt‘)
info = {‘age‘:22, ‘job‘:‘it‘)
name = [‘alex‘, ‘rain‘, ‘test‘]
d[‘name‘] = name
d[‘info‘] = info
d[‘date‘] = datetime.datetime.now()
d.close()
d = shelve.open(‘shelve_test.txt‘)
print(d.get(‘test‘))
print(d.get(‘name‘))
print(d.get(‘time‘))
d.close()
标签:txt imp shelve 说明 import port get 方式 inf
原文地址:https://www.cnblogs.com/my-love-is-python/p/9076261.html