擅长:python、mysql、java
<p>返回一个元组列表,该列表包含(外部列表索引、内部列表索引),设计为使您要查找的项可以位于多个内部列表中:</p>
<pre><code>l = [['apple','banana','kiwi'],['chair','table','spoon']]
def findItem(theList, item):
return [(ind, theList[ind].index(item)) for ind in xrange(len(theList)) if item in theList[ind]]
findItem(l, 'apple') # [(0, 0)]
findItem(l, 'spoon') # [(1, 2)]
</code></pre>