python报错时间:2023-03-09 15:58:40 报错1 UnboundLocalError: local variable 'x' referenced before assignment 定义了一个全局参数,但是在函数中直接改变参数值,就会报这个错误。例如 x=0 def my_test(): print x x=1 修改方案1 x=0 def my_test(x): print x x=1 修改方案2 x=0 def my_test(): global x print x x=1