Http://www.jb51.net/article/15714.htm
1. Copy.copy a shallow copy copies only the parent object and does not copy the inner sub-objects of the object.
2. copy.deepcopy deep copy copy objects and their sub-objects
A good example:
1 ImportCopy2A = [1, 2, 3, 4, ['a','b']]#Original Object3 4b = A#assignment, a reference to a passing object5c = Copy.copy (a)#object Copy, shallow copy6D = Copy.deepcopy (a)#object Copy, deep copy7 8A.append (5)#Modify Object A9A[4].append ('C')#Modify the [' A ', ' B '] Array object in Object aTen One Print('A =', a) A Print('B =', B) - Print('C =', c) - Print('d =', D) the - #Run Results - " " - a = [1, 2, 3, 4, [' A ', ' B ', ' C '], 5] + B = [1, 2, 3, 4, [' A ', ' B ', ' C '], 5] - C = [1, 2, 3, 4, [' A ', ' B ', ' C ']] + d = [1, 2, 3, 4, [' A ', ' B ']] A " "
Python Copy objects (deep copy deepcopy and shallow copy copy)