常見的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是局部變
相關文章
相關標籤/搜索