shelve模塊

 shelve模塊比pickle模塊簡單,只有一個open函數,返回相似字典的對象,可讀可寫;key必須爲字符串,而值能夠是python所支持的數據類型python

import shelve
 
f = shelve.open(r'shelve.txt')
 
# f['stu1_info']={'name':'alex','age':'18'}
# f['stu2_info']={'name':'alvin','age':'20'}
# f['school_info']={'website':'oldboyedu.com','city':'beijing'}
#
#
# f.close()
 
print(f.get('stu_info')['age'])
相關文章
相關標籤/搜索