The deep and shallow copy method of the list

depth copy

shallow copy

x.copy---This type of copy appears nested in the list to change the content after the copy, and the copy body will also be modified, because the nested column as a whole belongs to a memory address

Deep copy [First import the copy toolkit]

copy.deepcopy(x)-----Copy together with the elements inside the nest

Guess you like

Origin blog.csdn.net/qq_42954795/article/details/127614527