是否可以通过将全局变量传递给Python函数来修改它?

时间:2019-05-27 22:31:29

标签: python parameter-passing global

我试图通过将全局变量传递给函数来修改它,如下所示。

test = -99
def testFunc(tester):
    tester = 1

testFunc(test)
print(test)

此代码打印:-99

我可以想象通过将测试传递到testFunc中,我将能够对其进行修改。为什么这不起作用?

0 个答案:

没有答案