Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you may not be able to execute some actions.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
在函数里定义了一个变量,但是后面还需要用到
直接在函数外面定义变量就行,函数里面要用就加global修饰。
a = 1 def func1(): global a a = 2 def func2(): global a a += 1 func1() func2() print(a)
最后输出 3
好的。。。。。。