python在使用全局变量时需要在函数内部先对变量加一个global
s = 0
def test():
global s
s +=2
print(s)
if __name__ == "__main__":
test()
python在使用全局变量时需要在函数内部先对变量加一个global
s = 0
def test():
global s
s +=2
print(s)
if __name__ == "__main__":
test()