首页 > TAG信息列表 > issubset

set(集合)

#交集 a = set([1,2,3,4,5]) b = set([4,5,6,7,8]) print(a.intersection(b)) print(a & b) #并集 print(a.union(b)) #第一种 print(a|b) #第二种 #差集 print(a.difference(b)) print(a - b) print(b.difference(a)) print(b - a) #对称差集 print(a.symmetric_difference(b)) p