python set集合简单使用

Python 提供了强大的集合操作方法,我们可以完成数学中集合的并集、交集、差集等操作,如下:

>>> a = {1,2,3}
>>> b = {3,4,5}
>>> a.union(b)
set([1, 2, 3, 4, 5])
>>> 
>>> a.difference(b)
set([1, 2])
>>> 
>>> a.intersection(b)
set([3])
原文地址:https://www.cnblogs.com/guigujun/p/6133850.html