内置函数_locals_变量相关

 

 

描述

locals() 函数会以字典类型返回当前位置的全部局部变量。

 

示例代码:

 

num1 = 100


def func():
    num2 = 10
    print(locals())


func()

"""
    执行结果:
    {'num2': 10}
"""
View Code

 

posted @ 2021-04-02 16:44  御姐玫瑰  阅读(39)  评论(0编辑  收藏  举报
levels of contents