全局变量用大写,局部变量用小写
全局变量用大写,局部变量用小写
NAME=['cat','dog'] def change_name(): global NAME name='parrow' print('my name is ',name) change_name() print(NAME)
代码的执行步骤
1 NAME ='cloud' def huangwei(): 3 name='rain' 4 print(name) def liuhai(): 6 name ="black" 7 print(name) def muuli(): 10 name='white' 11 print(name) 8 print(name) 9 muuli() 5 liuhai() 12 print(name) 2 huangwei()