最佳答案
下面的代码给出了错误UnboundLocalError: local variable 'Var1' referenced before assignment
:
Var1 = 1
Var2 = 0
def function():
if Var2 == 0 and Var1 > 0:
print("Result One")
elif Var2 == 1 and Var1 > 0:
print("Result Two")
elif Var1 < 1:
print("Result Three")
Var1 =- 1
function()
我该如何解决这个问题?