简单示例
import shelve f = shelve.open(r'shelve.txt') f['info'] = {'name':'ftl', 'age':23, 'sex': 'male'} f['cou'] = 'China' # 写完以后直接执行即可 # 读取 print(f.get('info'))