【发布时间】:2016-10-27 07:31:35
【问题描述】:
我有 list1= [com.x1 ,com.x2 com.x3] 并且我还有一个列表 list2= [com.x3]。
我还需要一个列表,如 list3=[com.x1 , com.x2 ],例如 list1-list2。
请帮帮我。
【问题讨论】:
-
你听说过set吗?
-
您可以使用列表推导式或生成器表达式(如果您正在处理大列表)
[x for x in list1 if x not in list2]或(x for x in list1 if x not in list2)。
标签: python python-2.7 python-3.x