如何在一个函数内部修改全局变量
#coding=utf-8 a=5 def test(): global a print(a) test()
输出
5
例子
#coding=utf-8 a=5 def test(): global a a=10 test() print(a)
输出
10
#coding=utf-8 a=5 def test(): global a print(a) test()
输出
5
例子
#coding=utf-8 a=5 def test(): global a a=10 test() print(a)
输出
10