set
set有去重和排序功能
>>> a=[1,2,3,3,3,4,5,1,6,7]
>>> b=set(a)
>>> type(b)
<type 'set'>
>>> print b
set([1, 2, 3, 4, 5, 6, 7])
>>> x = set('spam')
>>> y = set(['h','a','m'])
>>> x, y
(set(['a', 'p', 's', 'm']), set(['a', 'h', 'm']))
>>> x & y # 交集
set(['a', 'm'])
>>> x | y # 並集
set(['a', 'p', 's', 'h', 'm'])
>>> x - y # 差集
set(['p', 's'])