python_1 = ['charon','pluto','ran','charon']
linux_1 = ['ran','xuexue','ting'] p_s = set(python_1)
l_s = set(linux_1)
#交叉并集
print(p_s.symmetric_difference(l_s))
print(p_s^l_s)
set定义的 集合能追加,能删除是可变数据类型
frozenset定义的集合是不可变的
简单去重,但是不可考虑顺序
name = ["charon","charon","pluto"]
s = set(name)
print(s)
name = list(s)
print(name) 结果:
{'pluto', 'charon'}
['pluto', 'charon']