python shelve模块

import shelve

# 将一个字典写入文件
dic = shelve.open(r'shelve_txt')
dic['info'] = {'name': "Kehaimin"}

# 使用存入文件的字典
dic = shelve.open(r'shelve_txt')
print(dic['info'], type(dic['info']))
# {'name': 'Kehaimin'} <class 'dict'>
原文地址:https://www.cnblogs.com/kehaimin/p/11466219.html