擅长:python、mysql、java
<p>查找两次出现的项目的索引</p>
<pre><code>>>> L = [1,2,3,1,4,6,6]
>>> from collections import Counter
>>> c = Counter(L)
>>> for key in filter(lambda x: c[x] == 2, c):
one = L.index(key)
two = L.index(key, one+1)
print(key, 'found at indexes', ' '.join(map(str, [one, two])))
1 found at indexes 0 3
6 found at indexes 5 6
</code></pre>