Getting the python namespace

name = 'tank'

What is the name space?

Store name space

If you want to access a variable value, you must first access the corresponding namespace binding relationship to get the name and address of the corresponding memory

Namespace Category:

1, built-in namespace:

    python提前给你的定义完的名字,就是存在内置名称空间

2, global name space

    存放于文件级别的名字,就是全局名称空间
    if while for 内部定义的名字执行之后都存放于全局名称空间

3, the local name space

    函数内部定义的所有名字都是存放与当前函数的内置名称空间

The life cycle:

1, built-in namespace

    在python解释器启动的时候生效,关闭解释器的时候失效

2, global name space

    当你启动当前这个py文件的时候生效,当前页面代码执行结束之后失效

3, the local name space

    当你调用当前函数时生效,函数体最后一行代码执行结束就失效

Guess you like

Origin www.cnblogs.com/cnhyk/p/11838435.html