擅长:python、mysql、java
<p>类型注释在运行时具有<em>无</em>效果。仅仅因为您已经指出<code>myUnionB</code><em>应该是<code>int</code>或者是{<cd3>}的列表,您实际上从未将其定义为一个列表,更不用说包含至少3个元素的列表,这样您就可以将其分配给<code>myunionB[2]</code>。在</p>
<p>错误消息可能更清楚;<code>myunionB</code>是不受支持的目标,因为该名称尚不存在。变量注释不会“创建”一个变量,因为它不会给被注释的名称赋值(甚至是一个隐式的<code>None</code>)。在</p>