shelve模块

能够支持多次load

import shelve

f = shelve.open('test_shleve')
date = {
    'roles':[
        {'role': 'monster', 'type': 'pig', 'HP': '50'},
        {'role': 'hero', 'type': '关羽', 'HP': '80'}
    ]
}
l = {'a':1, 'b':2}

f['date'] = date    #序列化
f['l'] = l               #序列化
print(f.get('date'))
print(f.get('l'))
f['date'] = [1,2,3]
原文地址:https://www.cnblogs.com/zhengyiqun1992/p/10087224.html