python的交集、并集、差集、对称差集

[个人博客,欢迎来撩 fangzengye.com](http://fangzengye.com)

1.交集

x & y # 交集 

2.并集

x | y # 并集 

3.差集

x - # 差集 

4.对称差集

a_list = [1, 2, 3, 4, 5]
b_list = [1, 4, 5]
ret_list = list(set(a_list)^set(b_list))
print(ret_list)

参考资料

https://blog.csdn.net/weixin_42575020/article/details/100038435

posted @ 2020-12-16 20:58  开源的Boy  阅读(486)  评论(0)    收藏  举报