代码如下:
s=1 def sum(): s=100 print(s) sum() print(s)
输出:100
1
代码变为:
s=1 def sum(): global s s=200 print(s) sum() print(s)
输出:200
200