https://www.zhihu.com/column/c_1216656665569013760
集合的运算
set2 = {1, 3, 4, 5, 6, 7, 8} set3 = {4, 5, 6, 7, 8, 9, 0, '1', 'a'} # 交集 # print(set2 & set3) # print(set2.intersection(set3)) # 加赋值 # set2 |= set3 # 并集 # print(set2 | set3) # print(set2.union(set3)) # 差集 # print(set2 - set3) # print(set2.difference(set3)) # 差集加赋值 # set2 -= set3 # print(set2) # 对称差 # print(set2 ^ set3) # print(set2.symmetric_difference(set3)) # print((set2 | set3) - (set2 & set3))