标签:app 内存 pen 浅拷贝 import 深拷贝 bsp nbsp append
a = [11,22,33]
b = a #指向同一个内存地址
id (a)#2585545319536
id(b)#2585545319536
#浅拷贝
------------------------------
#深拷贝,拷贝出一个新的内存地址
import copy
c = copy.deepcopy(a)
id(a) 2541445843848
id(c) 2541443545224
>>> a= [11,22,33]
>>> b=a
>>> id(a)
2541443545224
>>> id(b)
2541443545224
>>> import copy
>>> c = copy.deepcopy(a)
>>> id(c)
2541445843848
>>> id(a)
2541443545224
>>> a.append(44)
>>> a
[11, 22, 33, 44]
>>> b
[11, 22, 33, 44]
>>> c
[11, 22, 33]
>>>
标签:app 内存 pen 浅拷贝 import 深拷贝 bsp nbsp append
原文地址:https://www.cnblogs.com/keawen/p/9692891.html