python中集合之間的並集、交集、差集等集合之間的組合,運用函數方法和簡寫方法進行筆記歸類,以便查詢python
a=set("abc") b=set("abcde") print("*"*20) print("交集") print(a&b) print(a.intersection(b)) print("*"*20) print("並集") print(a|b) print(a.union(b)) print("*"*20) print("差集") print(a-b) print(a.difference(b)) print(b-a) print(b.difference(a)) print("*"*20) print("對稱差集") print(a.symmetric_difference(b)) print(a^b) print(b.symmetric_difference(a)) print("*"*20) print("子集判斷") print(a<b) print(a.issubset(b)) print("*"*20) print("父集判斷") print(a>b) print(a.issuperset(b))