运行结果:
orangemarmot ODW [:~/python/python-scripts] 1206$ python set.py
set(['a', 1, 2])
set(['a', 1, 2, 3, 4, 'c', 'b'])
set([3, 'b'])
set(['c', 3, 4, 'b'])
==========
>>> a=set((1,2,3,"a","b"))
>>> set(a)
set(['a', 1, 2, 3, 'b'])
>>> b=set((1,2,4,"a","c"))
>>> a
set(['a', 1, 2, 3, 'b'])
>>> b
set(['a', 1, 2, 4, 'c'])
>>> a & b
set(['a', 1, 2])
>>> a.intersection(b)
set(['a', 1, 2])
>>> a | b
set(['a', 1, 2, 3, 4, 'c', 'b'])
>>> a.union(b)
set(['a', 1, 2, 3, 4, 'c', 'b'])
>>> a-b
set([3, 'b'])
>>> a^b
set(['c', 3, 4, 'b'])