删除list中所有符合条件的元素

a = [10, 20, 30, 40, 20, 30, 40, 20, 70, 20]
a = [x for x in a if x != 20]

a:

[10, 30, 40, 30, 40, 70]

猜你喜欢

转载自blog.csdn.net/tcx1992/article/details/80335762