#-*-coding:cp936-*-#python 27#xiaodeng#global statement (Python Study manual page 422) #实际上就是一个名为__builtin__的模块, but must be import before use, Because the variable name builtin itself does not have a pre-built #global statement, namespace declarations tell Python to plan to generate one or more global variables. #全局变量名小结: #1, the global variable is the variable name at the top level inside the module file, and if the global variable is assigned a value within the function, it must go through Global declaration # # #, the global variable name is not declared inside the function or can be referenced # case x=88def func (): Global x x=99 print xprint x#88func () #99, func () is called, the x inside the function goes up to a global variable and the x is assigned, causing the value of the external X to be modified by the print x#99
Global Statement (Python Study manual, page 422)