python的复制,拷贝,和深拷贝。
>>> a=[23,3]
>>> b=a
>>> b.append(234)
>>> a
[23, 3, 234]
>>> import copy
>>> a=[23,3,3,[23,3]]
>>> b= copy.copy(a)
>>> b
[23, 3, 3, [23, 3]]
>>> b[3].append(34)
>>> a
[23, 3, 3, [23, 3, 34]]
>>> b
[23, 3, 3, [23, 3, 34]]
python的复制,拷贝,和深拷贝。
>>> a=[23,3]
>>> b=a
>>> b.append(234)
>>> a
[23, 3, 234]
>>> import copy
>>> a=[23,3,3,[23,3]]
>>> b= copy.copy(a)
>>> b
[23, 3, 3, [23, 3]]
>>> b[3].append(34)
>>> a
[23, 3, 3, [23, 3, 34]]
>>> b
[23, 3, 3, [23, 3, 34]]