1、差集
# t有而s无
>>> s = [1, 2, 3, 4]
>>> t = [4, 5, 6]
>>> list(set(t).difference(set(s)))
[5, 6]
2、并集
>>> list(set(t).union(set(s)))
[1, 2, 3, 4, 5, 6]
3、交集
>>> list(set(t).intersection(set(s)))
[4]
哈哈,以上就是python小工具关于list的交集,并集,差集的介绍。有兴趣欢迎关注公众号:python小工具。一起学习pyhton和pandas