原文:http://www.kuqin.com/abyteofpython_cn/ch07s03.html
#!/usr/bin/python
# Filename: func_global.py
def func():
global x
print 'x is', x
x = 2
print 'Changed local x to', x
x = 50
func()
print 'Value of x is', x
输出
$ python func_global.py
x is 50
Changed global x to 2
Value of x is 2