Python copy与deepcopy的区别
import copy
origin = [1, 2, [3, 4]]
#origin 里边有三个元素:1, 2,[3, 4]
cop1 = copy.copy(origin)
cop2 = copy.deepcopy(origin)
cop1 == cop2
True
cop1 is cop2
False
#cop1 和 cop2 看上去相同,但已不再是同一个object
origin[2][0
转载
2017-08-04 00:26:09 ·
231 阅读 ·
0 评论