代码示例:(标识:python_scope_6)
python_scope_6.py
x = 100

def myfunc():
  global x
  x = 200

myfunc()

print(x)
运行结果: