交集:intersection,all elements that are in both sets
差集:difference, all elements that are in this set but not the others
方法一,用set类
b1=[1,2,3]
b2=[2,3,4]
print(list(set(b1).difference(set(b2))))
print(list(set(b1).intersection(set(b2))))
print(list(set(b1).union(set(b2))))
方法二:
b1=[1,2,3]
b2=[2,3,4]
intersection = [val for val in b1 if val in b2]
difference = [val for val in b1 if val not in b2]
print(intersection, difference)