# 'A and B have the same id' => 'A is in sync with B' / 'A And B Are attached to the same thing'
A = [0, [1, 2]]
B = A
print(id(A) == id(B)) # True
A[0] = -1
print(A, B) # same
A[1].append(3
Python | 复制拷贝(copy)的六种方法 举例辨析
最新推荐文章于 2024-05-09 14:56:38 发布
# 'A and B have the same id' => 'A is in sync with B' / 'A And B Are attached to the same thing'A = [0, [1, 2]]B = Aprint(id(A) == id(B)) # TrueA[0] = -1print(A, B) # sameA[1].append(3)print(A, B) # sameimport copy# 'A and B have different
摘要由CSDN通过智能技术生成