擅长:python、mysql、java
<p>最好的方法可能是使用<a href="https://docs.python.org/tutorial/datastructures.html#more-on-lists" rel="noreferrer">list method .index</a>。</p>
<p>对于列表中的对象,可以执行以下操作:</p>
<pre><code>def __eq__(self, other):
return self.Value == other.Value
</code></pre>
<p>任何你需要的特殊处理。</p>
<p>您还可以将for/in语句与enumerate(arr)一起使用</p>
<p>查找值为100的项的索引的示例。</p>
<pre><code>for index, item in enumerate(arr):
if item > 100:
return index, item
</code></pre>
<p><a href="http://www.daniweb.com/forums/thread174502.html" rel="noreferrer">Source</a></p>