def func(x): print 'x is', x x = 2 print 'Changed local x to', x x = 50 func(x) print 'x is still', x 结果: x is 50 Changed local x to 2 x is still 50 在函数内改变全局变量的值(global) def func(): global x print 'x is', x x = 2 print 'Changed local x to', x x = 50…