|
如题,定义一个list,然后再次被list包含一次,却无法删除元素,如下,请问大侠为什么?
# def a list
p = list(range(1,5))
print(p)
# 被list包含一次的p的切片值
print(list(p)[2])
# 删除该切片值
del list(p)[2]
print(list(p)) # 被list包含一次的p的数据没变? why?
del p[1]
print(p) # 数据被删除
结果
[1, 2, 3, 4]3[1, 2, 3, 4][1, 3, 4]
|
|