#LEGB法则--变量的查找顺序
a = 1
def outer():
b = 2
def inner():
c = 3
print(c) # local局部作用域
print(b) # enclosing嵌套函数的外部函数作用域
print(a) # global全部作用域
print(max) # 内置作用域
inner()
outer()
运行结果
3
2
1
python 的LEGB法则--变量的查找顺序
猜你喜欢
转载自blog.csdn.net/qq_45687410/article/details/109258594
今日推荐
周排行