python函数中使用全局变量
2013-01-10 21:41
579 查看
x = 1
def func():
global x
x = 2
print "old x is: ", x
func()
print "new x is:", x
def func():
global x
x = 2
print "old x is: ", x
func()
print "new x is:", x
相关文章推荐
- 10 Python 函数内使用全局变量注意项
- python 在函数中使用全局变量的注意事项
- python 在函数中使用全局变量的注意事项
- 5.1 Python 函数-默认参数,*args,**kwargs的使用;作用域-局部空间使用全局变量需要注意的事项等
- Python在函数中使用全局变量的问题
- python3函数内全局变量使用global
- php预定义变量,超全局变量,魔术方法,特殊函数变量使用
- Python 继承结构中全局变量的使用
- python使用全局变量(global)
- python嵌套函数使用外部函数变量的方法(Python2和Python3)
- 【python】*函数:全局局部变量、内部函数、闭包
- Matlab函数文件中全局变量的使用
- Python类方法、静态方法、全局变量的使用
- python通过函数属性实现全局变量的方法
- 在C++工程中main函数之前跑代码的廉价方法(使用全局变量和全局函数)
- Php 中全局变量在函数中使用时必须申明为全局
- Python函数中的局部变量和全局变量
- python多文件使用同一个全局变量的定义和使用方法
- 3.8 Python函数中的局部变量和全局变量
- Python 全局变量的使用