‘‘‘
input
‘‘‘
import os
x=10
if 13 > 3:
y=20
if 3 == 3:
z=30
##### func=函数的内存地址
def func():
a=111
b=222
class Foo:
pass
def func(a,b):
pass
func(10,1)
func(11,12)
func(13,14)
func(15,16)
内置名称空间
全局名称空间
局部名称空间
##### input=333
def func():
##### input=444
print(input)
func()
input=333
def func():
input=444
func()
print(input)
def func():
print(x)
x=111
func()
x=1
def func():
print(x)
def foo():
x=222
func()
foo()
input=111
def f1():
def f2():
##### input=333
print(input)
input=222
f2()
f1()
x=111
def func():
print(x) #####
x=222
func()
x=111
def foo():
print(x,id(x))
def bar():
print(x,id(x))
foo()
bar()
print(x,id(x))
def foo(x):
def f1():
def f2():
print(x)
LEGB
##### builtin
##### global
def f1():
##### enclosing
def f2():
##### enclosing
def f3():
##### local
pass
原文:https://www.cnblogs.com/abldh12/p/15209041.html