如图,
a=b // a is b
c=b.copy() // c not b
为什么呢==
其次,在上图的基础上,为什么 a=1000 后,b依然不变,在这点上貌似 = 与 copy 都这样。。。混成一锅粥了,求高人指点迷津
= 是引用,python中缺省都是引用
copy是复制一个对象。所以产生一个新对象,里面的数据复制了一份
- A shallow copy constructs a new compound object and then (to the extent possible) inserts references into it to the objects found in the original.
- A deep copy constructs a new compound object and then, recursively, inserts copies into it of the objects found in the original.
同一个对象与不同对象的区域,判断依据是地址是否相同