擅长:python、mysql、java
<p>有一些可能的解决办法</p>
<ol>
<li>您可以直接访问列表元素:<code>Output[0]</code>或<code>Output[3]</code></li>
<li>在python中以编程方式定义变量是可能的,您可以在这里阅读更多关于它的内容:<a href="https://stackoverflow.com/questions/4859217/programmatically-creating-variables-in-python">Programmatically creating variables in Python</a>。但请记住,这是一种非常糟糕的做法,所以您可能不想使用它</李>
<li>看来解决这个问题的最佳方法是使用字典理解:</li>
</ol>
<pre class="lang-py prettyprint-override"><code>output = ['1)', 'JP', '*00000.0000/UNT', 0.07704, 61628.21, '0%(E)', 0.0, 'ND']
result = {f"var{index}": value for index, value in enumerate(output)}
print(result['var0']) # 1)
print(result['var1']) # JP
</code></pre>
<p>您可以在此处阅读有关词典理解的更多信息:<a href="https://www.programiz.com/python-programming/dictionary-comprehension" rel="nofollow noreferrer">https://www.programiz.com/python-programming/dictionary-comprehension</a></p>
<p>它将适用于任何长度的列表。另外,请注意,<code>f""</code>字符串正在使用Python 3.8+,因此如果您使用的是旧版本,请将其替换为<code>"".format</code>。有关字符串格式的详细信息:<a href="https://realpython.com/python-string-formatting/" rel="nofollow noreferrer">https://realpython.com/python-string-formatting/</a></p>