#交集
a = [1,2,3,4] b = [2,4,5,5,7] intersection = list(set(a) & set(b))
>>[2,4]
#并集
a = [1,2,3] b = [5,7,3] unionset = list(set(a).union(set(b)))
>>[1,2,3,5,7]
#差集
a = [1,2,3] b = [1,3,5] #b有而a没有的元素 difference = list(set(b).difference(set(a)))
>>[5]
#补集 a = [2,3] b = [1,2,5,7] complementaryset = list(set(b) - (set(a)))
>>[1,5,7]