Python3.8文档(https://docs.python.org/3.8/reference/simple_stmts.html#the-global-statement)说:
Names listed in a global statement must not be defined as formal parameters or in a for loop control target, class definition, function definition, import statement, or variable annotation.
“在变量注释中”是什么意思?例如,当我尝试在Python3.7中的全局注释上使用类型注释时,我得到一个错误:
global x
x: int
给出SyntaxError: annotated name 'x' can't be global
然而,根据https://bugs.python.org/issue34939的说法,这种行为是一个bug,在3.8中执行良好时,它似乎已经被修复
那么这条线限制了什么呢
目前没有回答
相关问题 更多 >
编程相关推荐