1 a = {1,2,3,4,5}
2 b = {1,6,3,9,10}
3 c = {1,3}
4 d = {6,7,8}
#求交集
print(a.intersection(b))
print(a & b)
#求并集
print(a.union(b))
print(a | b)
#求差集
print(a.difference(b)) #去掉a和b相同的值,保留a,反过来一样
print(a - b)
#子集
print(c.issubset(a)) #C是A的子集
print(a.issuperset(c)) #A是C的父集
#对称差集(去掉重复)
print(a.symmetric_difference(b))
print(a ^ b)
#添加
a.add(999) #添加一个
a.update({888,777}) #添加多项
#删除
a.remove(888)
#判断
X in a
X not in a