原始数组如:
arr = range(1,10)
print arr
# [1, 2, 3, 4, 5, 6, 7, 8, 9]
New将此原始数组提供给新变量x
和y
,
x = arr
y = arr
print arr, x, y
# [1, 2, 3, 4, 5, 6, 7, 8, 9] [1, 2, 3, 4, 5, 6, 7, 8, 9] [1, 2, 3, 4, 5, 6, 7, 8, 9]
更新原始数组,
arr.extend([10,11])
print arr, x, y
# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
或只更新x
:
x.extend([12, 13])
print x, arr
# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
为什么?