如何判断一个列表中的元素是否在另一个列表中


如何判断一个列表中的元素是否在另一个列表中

From:

https://blog.csdn.net/chenpe32cp/article/details/81945335

 

方法一:

a = [1,2,3]
b = [2,3,4,5]
inter = [i for i in a if i in b]
print(inter)


方法二:

a = [1,2,3]
b = [2,3,4,5]
inter = list(set(a).intersection(set(b)))
print(inter
--------------------- 
作者:chenpe32cp 
来源:CSDN 
原文:https://blog.csdn.net/chenpe32cp/article/details/81945335 
版权声明:本文为博主原创文章,转载请附上博文链接!

  

posted on 2019-04-12 13:54  cdekelon  阅读(1669)  评论(0)    收藏  举报

导航