标签:set,puthon,入门,999,list,差集,print,集合,difference From: https://www.cnblogs.com/Remick/p/17056280.html
list_1 = [1,3,5,7,9]
list_1 = set(list_1)
list_2 = set ([2,4,6,8,10])
print(list_1,list_2)
# 交集
print(list_1.intersection(list_2))
# 并集
print(list_1.union(list_2))
# 差集 in list_1 but not in list_2
print(list_1.difference(list_2))
print(list_2.difference(list_1))
#子集
print(list_1.issubset(list_2))
print(list_1.issuperset(list_2))
# 对称差集
print(list_1.symmetric_difference(list_2))
print("----------------------------------")
# 字符交集
print(list_1 & list_2)
#union 并集
print(list_2 | list_1)
# difference 求差集
print(list_1 - list_2) #in list 1 but not in list2
# 对称差集
print(list_1 ^ list_2)
list_1.add(999) #添加一项
print(list_1)
list_1.update([888,999,555]) #添加多项
print(list_1)
list_1.remove('999') # 删除一项
list_1.pop('888') #删除