代码示例:(标识:python_variables_global_2)
python_variables_global_2.py
x = "awesome"

def myfunc():
  x = "fantastic"
  print("Python is " + x)

myfunc()

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