浅拷贝 = 只拷贝第一层
深拷贝 = 克隆一份
s = [1,'zhang','age']
s2 = s.copy()
print(s2)
s2[0] = 2
print(s2)
print(s)
s = [[1,2],'zhang','age']
s3 = s.copy()
print(s3)
s3[1] = 'liu'
print(s3)
print(s)
s3[0][1] = 3
print(s3)
print(s)
import copy
husband = ['zhang',123,[15000,9000]]
wife = husband.copy()
wife[0] = 'liu'
wife[1] = 345
qu = copy.copy() #浅拷贝
qu = copy.deepcopy(husband) #深拷贝
qu[0] = 'qu'
qu[1] = 666
qu[2][1] -= 1999
husband[2][1] -= 3000
print(wife)
print(qu)
来源:CSDN
作者:去西天
链接:https://blog.csdn.net/weixin_44258331/article/details/104376887