有集合 x与y
x = {1,2,3,4,5} y = {4,5,6,7,8}
x和y的交集为 {4,5}
x和y的对称差集{1, 2, 3, 6, 7, 8}
x和y的并集{1, 2, 3, 4, 5, 6, 7, 8}
x与y的差集(x.difference(y)){1, 2, 3}
y与x的差集(x.difference(y)){8, 6, 7}