擅长:python、mysql、java
<p>您可以使用<code>enumerate()</code>:</p>
<pre><code>for index, sublist in enumerate(execlist):
if sublist[0] == mynumber:
execlist[index][1] = myctype
execlist[index][2] = myx
execlist[index][3] = myy
execlist[index][4] = mydelay
# break
</code></pre>
<p>如果<code>execlist</code>最多只包含一个子列表,而该子列表的第一项可以等于<code>mynumber</code>,则可以删除<code>#</code>;否则,将无用地循环遍历该列表的其余部分。</p>
<p>如果<code>itemnumbers</code>事实上是唯一的,那么最好使用字典,或者至少使用<code>OrderedDict</code>,这取决于您打算对数据执行的其他操作。</p>