Deep copy of the python list (list [:]) and shallow copy

python list deep and shallow copy copy


know how:

a=[1,2,3]
print(id(a)) #out:140076409282432
a=[1,2,3,4]
print(id(a)) #out:140076409279264

a=[1,2,3]
print(id(a)) #out:140578182881152
a[:]=[1,0]
print(id(a)) #out:14057818288115

The following explanation of this blog is also very clear, from a different perspective. Link
https://blog.csdn.net/qq_43230540/article/details/84788151?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

Published 20 original articles · won praise 1 · views 204

Guess you like

Origin blog.csdn.net/weixin_43973433/article/details/104860919