代码示例:(标识:python_variables_global_3)
python_variables_global_3.py
def myfunc():
  global x
  x = "fantastic"

myfunc()

print("Python is " + x)
运行结果: