请问两个test不是都为局部变量吗?为什么会报错呢?
请问两个test不是都为局部变量吗?为什么会报错呢?
>>> def test():
test=90
return test
>>> def main():
test=test()
print(test)
>>> main()
[color=#FF0000]Traceback (most recent call last):
File "<pyshell#21>", line 1, in <module>
main()
File "<pyshell#20>", line 2, in main
test=test()
UnboundLocalError: local variable 'test' referenced before assignment[/color]