Python copy object (deep copy and shallow copy), pythondeepcopy
Http://www.jb51.net/article/15714.htm
1. copy. copy: only the parent object is copied, and the internal sub-objects of the object are not copied.
2. copy. deepcopy: Deep copy object and its sub-objects
A good example:
1 import copy 2 a = [1, 2, 3, 4, ['A', 'B'] # original object 3 4 B = a # assign a value, upload object reference 5 c = copy. copy (a) # object copy, shortest copy 6 d = copy. deepcopy (a) # object copy, deep copy 7 8. append (5) # modify object a 9 a [4]. append ('C') # modify ['A', 'B'] array object 10 11 print ('a = ', a) in object) 12 print ('B =', B) 13 print ('C = ', c) 14 print ('d =', d) 15 16 # running result 17 '''18 a = [1, 2, 3, 4, ['A', 'B', 'C'], 5] 19 B = [1, 2, 3, 4, ['A', 'B', 'C'], 5] 20 c = [1, 2, 3, 4, ['A', 'B', 'C'] 21 d = [1, 2, 3, 4, ['A ', 'B'] 22 '''