一、定义
也是序列化数据的模块,唯一区别为只有一个open函数,返回类似字典的对象,可读可写;key必须为字符串,而值可以是python所支持的数据类型
二、实例
1 import shelve 2 3 f=shelve.open(r'sheve.txt') 4 # f['stu1_info']={'name':'egon','age':18,'hobby':['piao','smoking','drinking']} 5 # f['stu2_info']={'name':'gangdan','age':53} 6 # f['school_info']={'website':'http://www.pypy.org','city':'beijing'} 7 8 print(f['stu1_info']['hobby']) 9 f.close()