擅长:python、mysql、java
<p>如果您真的不能使用<code>int(indices[i])</code>(它对JoshAdel和我都有效),那么您应该可以使用<code>math.trunc</code>或{<cd3>}来解决它:</p>
<pre><code>import math
...
destinations[i] = sources[math.trunc(indices[i])] # truncate (py2 and py3)
destinations[i] = sources[math.floor(indices[i])] # round down (only py3)
</code></pre>
<p>据我所知,<code>math.floor</code>只适用于Python3,因为它在Python2中返回一个<code>float</code>。但是<code>math.trunc</code>则取整为负值。在</p>