常见的local variable 'x' referenced before assignment问题

def fun1(): x = 5 def fun2(): x *= 2 return x return fun2() 如上代码,调用fun1() 运行会出错:UnboundLocalError: local variable 'x' referenced before assignment。python 这是由于对于fun1函数,x是局部变
相关文章
相关标签/搜索