python列表的拷贝问题

1、使用冒号截断是深拷贝

a=[1,2,3,4]
b=[]
b.append(a)
a=a[:2]
a.reverse()
print(b)
“”“
输出:[[1, 2, 3, 4]]
”“”

你可能感兴趣的:(python,python)