x = [1,2,1,2,3,1,1,1,1,5] for i in x[::]: i if i == 1: x.remove(i) x print(x)
for循环使用remove删除元组中的指定元素
最新推荐文章于 2023-09-09 11:14:39 发布
x = [1,2,1,2,3,1,1,1,1,5] for i in x[::]: i if i == 1: x.remove(i) x print(x)