def fun1(): x = 5 def fun2(): x *= 2 return x return fun2() 如上代码,调用fun1() 运行会出错:UnboundLocalError: local variable 'x' referenced before assignment。 这是因为对于fun1函数,x是局部变量,对于fun2函数,x是非全局的外部变量。当在fun2
专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]
Copyright (C)ICode9.com, All Rights Reserved.
ICode9版权所有