Find an Exact Tuple Match in a List of Tuples and Return Its Index
This question already has an answer here:
使用list.index
:
>>> TupList = [('ABC D','235'),('EFG H','462')]
>>> TupList.index((u'EFG H',u'462'))
1
我认为你可以这样做
TupList = [('ABC D','235'),('EFG H','462')]
if ('ABC D','235') in TupList:
print TupList.index(i)
链接地址: http://www.djcxy.com/p/28108.html