标签:
>>> import shelve >>> db = shelve.open(‘a.db‘) >>> db[‘a‘]=[1,2,3,4] >>> db[‘b‘]=(1,‘a‘,‘c‘) >>> db[‘c‘]={‘a‘:‘a‘,‘b‘:‘b‘} >>> db {‘a‘: [1, 2, 3, 4], ‘c‘: {‘a‘: ‘a‘, ‘b‘: ‘b‘}, ‘b‘: (1, ‘a‘, ‘c‘)} >>> db.close()
>>> import shelve >>> s=shelve.open(‘a.db‘) >>> s {‘a‘: [1, 2, 3, 4], ‘c‘: {‘a‘: ‘a‘, ‘b‘: ‘b‘}, ‘b‘: (1, ‘a‘, ‘c‘)}
获取到的数据随意发挥。
标签:
原文地址:http://www.cnblogs.com/tiantiandas/p/python_shelve.html