g_num = 100 def demo(): # 若要修改全局变量使用global 关键字声明一下 global g_num g_num = 200 print("%d" % g_num) demo()