本文实例讲述了python实现通过shelve修改对象的方法,分享给大家供大家参考。 具体实现方法如下: import shelve she = shelve.open('try.she','c') for c in 'spam': she[c] = {c:23} for c in she.keys(): print c,she[c] she.close() she = shelve.open('try.she','c') print she['p'] she['p']['p'] = 42 #这样修改是不行,这只是修改了个临时对象 print she['p'] a = she['p'