一种字典形式储存数据的方式  

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()

posted on 2018-05-23 12:30  python我的最爱  阅读(132)  评论(0编辑  收藏  举报