擅长:python、mysql、java
<p>似乎您正在尝试使用<a href="https://stackoverflow.com/questions/374572/need-help-variable-creation-in-python">this</a>问题中标记的解决方案。在</p>
<p>如果您的目标是访问循环中的值,则应该使用列表。这种奇怪的带有数字的变量名概念在任何语言中都不应该使用。试试这个。在</p>
<pre><code>vals = ['foo', 'bar', 'blah', 67, -0.4, 'your mom']
for i in range(len(vals)):
print(vals[i])
</code></pre>
<p>这是一个由整数索引的值列表的正确方法,而不是将其放入变量名中。在</p>