当我尝试使用函数更改变量的内容时,它实际上并没有更改它,我该如何解决这个问题?
我试过了
myVariable = "not correct"
def changeVariable():
myVariable = "correct"
changeVariable()
print(myVariable)
但输出“不正确” 我也试过使变量全局
myVariable = "not correct"
def changeVariable():
global myVariable
myVariable = "correct"
changeVariable()
print(myVariable)
仍然输出“不正确”