擅长:python、mysql、java
<p>您可以重新创建相同的错误:</p>
<pre><code>global chosen2 #you're not creating chosen2, just saying you're about to create it, and when you do - it should be a global variable
chosen2[2]=2 #chosen2 has yet to be defined so how can you set anything?
</code></pre>
<p>您试图设置尚未定义的对象<code>two</code>的属性,首先必须说明您希望它是列表还是字典(或其他)。在</p>
^{pr2}$
<p><em>如前所述,我不认为您希望这是全局的(因为您希望能够创建具有不同chosen2值的类实例!</em></p>