标签:闭包 print 变量 osi from global oba turn port
什么是命名空间 == 对一个名字起作用的范围
# def test():
# print("----test----")
# import test
# test.test()
# from test import *
# LEGB规则 locals > enclosing function > globals > builtins(内件)# 查看内件 dir(__builtins__)
# L局部变量
# enclosing 闭包
a = 100 #全局变量
def test():
b = 200 #局部变量
print(locals)
# globals 查看全局变量
# locals 查看局部变量
# num = 100
# def test():
# num = 200
# print(num)
# test() #200
# 闭包
# num = 100
# def test1():
# num = 200
# def test2():
# # num = 300
# print(num)
# return test2
# ret = test1()
# ret()
标签:闭包 print 变量 osi from global oba turn port
原文地址:https://www.cnblogs.com/sklhtml/p/9447979.html