set集合的合并

操作符|用于求两个集合的并集,这也是一个按位或(OR)操作符(参见附录C)。在数学符号表示上,按位或操作与集合求并操作使用相同记号。

a=set([1,2,4])
b=set([4,5,6])
print a|b

输出:
set([1, 2, 4, 5, 6])

猜你喜欢

转载自blog.csdn.net/th_num/article/details/80339457