标签:
首先直接看例子:
>>> l1=[1,2,3]
>>> l11 = l1
>>> l2=[4,5,l1]
>>> l2
[4, 5, [1, 2, 3]]
>>> l3 = l2[:]
>>> l3
[4, 5, [1, 2, 3]]
>>> import copy
>>> l4 = copy.deepcopy(l2)
>>> l4
[4, 5, [1, 2, 3]]
>>> l2[1] = 6
>>> l2
[4, 6, [1, 2, 3]]
>>> l3
[4, 5, [1, 2, 3]]
>>> l4
[4, 5, [1, 2, 3]]
>>> l1[0] = 7
>>> l1
[7, 2, 3]
>>> l11
[7, 2, 3]
>>> l2
[4, 6, [7, 2, 3]]
>>> l3
[4, 5, [7, 2, 3]]
>>> l4
[4, 5, [1, 2, 3]]
说明:
标签:
原文地址:http://blog.csdn.net/u012123160/article/details/46313819