global1 = "" def o(): #global global1; global1=2; print(global1) def p(): print(global1) if __name__=="__main__": o() p()输出:21如果第4行不注释,就是在声明要对全局变量进行修改,输出为:22