内置函数_globals_变量相关

 

 

描述

globals函数作用:查看所有的全局变量

 

示例代码:

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


func()
View Code

 

运行结果:

"""
    执行结果:
    {
    '__name__': '__main__', 
    '__doc__': '\n    globals函数:\n    作用:\n        查看所有的全局变量\n', 
    '__package__': None, 
    '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x7f3b74758850>, 
    '__spec__': None, 
    '__annotations__': {}, 
    '__builtins__': <module 'builtins' (built-in)>, 
    '__file__': '/home/xyxifeng/PycharmProjects/chapter01/day09_高阶函数/hw_23_内置函数globals_变量相关.py', 
    '__cached__': None, 
    'num1': 100, 
    'func': <function func at 0x7f3b746cce60>}
"""
View Code

 

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