1. 程式人生 > 其它 >Python list的並集,交集,差集

Python list的並集,交集,差集

技術標籤:Python

a = []
b = []

並集

list(set(a).intersection(set(b)))

交集

list(set(a).union(set(b)))

差集

list(set(b).difference(set(a)))