This article describes the Python implementation through the shelve to modify the object of the method to share for everyone to reference.
The implementation methods are as follows:
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 # This modification is not possible, this just modifies a temporary object
print she[' P ']
a = she[' P '] #给临时对象绑定个名字
a[' p '] = "
she[' P '" = a
print she [' P ']
This article example test environment for Python2.7.6
The results of the program operation are as follows:
p {' P ':}
a {' A ':}
m {' m ':}
S {' s ':} {' P '
:} #原值是这样的 {'
P ':} #只是修改了临时对象 {' P ']: #绑定名字后, to achieve the purpose of the modification
Both the instance code and the running results are fully annotated to help you understand what it means. I hope this article will help you with your Python programming.