获取两个列表中的交集与差集

获取两个列表中的交集

可以使用set集合的intersection方法
例:
a = [1,2,3]
b = [3,4,5,6,2]
common = set(a).intersection.(set(b))
print(list(common))
输出:[2,3]

发布了30 篇原创文章 · 获赞 0 · 访问量 43

猜你喜欢

转载自blog.csdn.net/qq_41685616/article/details/105580576