返回列表 发帖

[问题求助] python如何求2个列表的并集

只搜索到交集的写法,并集的代码如何写?

Python中对列表list求交集
遍历b1,如果某个元素同时也存在于b2中,则返回

b1=[1,2,3]
b2=[2,3,4]
b3 = [val for val in b1 if val in b2]
print b3

返回列表