a = [1,2,3,4,5,9]b = [4,5,6,7,8]c = set(a)d = set(b)print(c | d) #并集print(c & d) #交集print(c - d) #差集 在c有d没有print(d - c) #差集 在d有c没有print(d ^ c) #反向交集print(c < d) #包含print(d > c) #包含
set集合
原文:https://www.cnblogs.com/TKOPython/p/11631503.html