【发布时间】:2010-11-05 18:33:08
【问题描述】:
我有一个列表列表,想检查它是否已经包含一个包含特定项目的列表。
从这个例子中一切都应该清楚了:
list = [[1,2],[3,4],[4,5],[6,7]]
for test in [[1,1],[1,2],[2,1]]:
if test in list:
print True
else:
print False
#Expected:
# False
# True
# True
#Reality:
# False
# True
# False
是否有一个函数可以比较列表中的项目而不管它们是如何排序的?
【问题讨论】:
-
[使用 Python 在另一个列表中搜索列表的值]的可能重复项(stackoverflow.com/questions/1695452/…)
-
for test in ...: print sorted(test) in list