python中的深拷贝
最早接触深拷贝是在C++中,深拷贝需要自己实现。现在用了python,感觉好多了。示例代码如下:
import copy import random a = [i for i in range(100)] a1 = copy.deepcopy(a) a2 = a random.shuffle(a1) print("a == a1 -> ", a == a1) print("a == a2 -> ", a == a2)
最早接触深拷贝是在C++中,深拷贝需要自己实现。现在用了python,感觉好多了。示例代码如下:
import copy import random a = [i for i in range(100)] a1 = copy.deepcopy(a) a2 = a random.shuffle(a1) print("a == a1 -> ", a == a1) print("a == a2 -> ", a == a2)