set找不同
list1 = ['a', 'b', 'c', 'c', 'd', 'd', 'd']
sentence = 'Welcome to my class'
print(set(list1))
print(set(sentence))
# {'c', 'b', 'a', 'd'}
# {' ', 't', 'm', 'c', 'e', 'l', 'a', 's', 'W', 'y', 'o'}
uni_char = set(list1)
uni_char.add('x')
print(set(uni_char))
# {'a', 'b', 'c', 'x', 'd'}
# 清空
uni_char.clear()
print(uni_char)
# set()
# uni_char.discard() 返回None 删掉后的结果需再次调用
print(uni_char.discard('x'))
# None
print(uni_char)
# {'c', 'a', 'b', 'd'}
set1 = uni_char
set2 = {'a', 'e', 'i'}
# 不同
print(set1.difference(set2))
# 相同
print(set1.intersection(set2))
# {'d', 'b', 'c'}
# {'a'}