标签:深拷贝 克隆 nihao 浅拷贝 not 深浅拷贝 复习 运算符 --
身份运算符:is , is not
成员运算符:in , not in
1.深浅拷贝
s = [‘nihao ‘, 2]
s1 = s.copy()
print(s1)
print(s,s1)
<1>浅拷贝(只会copy第一层次)
b=a[:] #b=a.copy()
-------------------------------
s = [[1, 2], ‘nihao‘, 2]
d = s
print(id(s))
print(id(d))
#32285040
#32285040
-------------------------------
s = [[1, 2], ‘nihao‘, 2]
d = s.copy()
print(id(s))
print(id(d))
#6726000
#6797272
<2>s深拷贝(克隆一份)
标签:深拷贝 克隆 nihao 浅拷贝 not 深浅拷贝 复习 运算符 --
原文地址:https://www.cnblogs.com/hq82/p/8901143.html