Global Statement (Python Study manual, page 422)

Source: Internet
Author: User
#-*-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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.