python可以用& - |等来生成新的集合 举个例子: a = {1,2,3,4} b = {3,4,5,6} print(a&b) print(a-b) print(a|b) 输出: 是不是和数学里面集合的操作一模一样,很神奇吧。