#set 集合
#初始化
# set1 = {1,'ww',2,3}
# print(set1)
#并集 union
# set1 = {1,'w',2,4,5,6}
# set2 = {'hah'}
# set3 = set1.union(set2)
# print(set3)
#差集 difference
# set1 = {1,'w',2,4,5,6}
# set2 = {1,'235',2,89,5,6}
# set3 = set1.difference(set2)
# print(set3)
# print(set1.difference(set2))
#交集 intersection
# set1 = {1,'w',2,4,5,6}
# set2 = {1,'235',2,89,5,6}
# set3 = set1.intersection(set2)
# print(set3)
#添加add
# set1 = {1,'w',2,4,5,6}
# set2 = {1,'235',2,89,5,6}
# set1.add("!@#")
# print(set1)
#删除 discard
# set1 = {1,'w',2,4,5,6}
# set2 = {1,'235',2,89,5,6}
# set2.discard(1)
# print(set2)
#清除clear
# set2 = {1,'235',2,89,5,6}
# set2.clear()
# print(set2)
网友评论