去除b中不属于a元素

a = [1,3,4,6,7]
b = [1,2,3,4,5,6,7,8,9]
print([i for i in b if i not in a])

[2, 5, 8, 9]

猜你喜欢

转载自blog.csdn.net/weixin_42785547/article/details/86361114