test.pyx = 10; # global variabledef func1(): print(x); # prints 10def func2() x = x + 1; # IDE shows error: "Unresolved reference of x(RHS of expression)def func3() global x; x = x + 1; # This works当x具有全局作用域时,为什么func2()不允许我修改它的值,尽管在func1()中可以访问它。以及为什么在func3()的情况下需要显式提及“ global”关键字?
添加回答
举报
0/150
提交
取消