python 去除两个列表的相同元素 # 去除交集

lst1 = [1, 2, 3, 5]
lst2 = [4, 5]

lst2 = [i for i in lst2 if not i in lst1 or lst1.remove(i)]

print(lst1):[1, 2, 3]
print(lst2):[4]
posted @ 2023-03-20 17:29  one剑飘红  阅读(87)  评论(0编辑  收藏  举报