Python 内建函数 - globals()

时间:2022-07-20 18:36:55

Manual

Return a dictionary representing the current global symbol table. This is always the dictionary of the current module (inside a function or method, this is the module where it is defined, not the module from which it is called).

直译

返回一个用以表示当前全局符号表的字典,这通常是当前模块的字典(在函数或方法内,域是定义模块的地方,而不是调用模块的域)。

实例

>>> globals()
{'__spec__': None, '__doc__': None, '__package__': None, '__builtins__': <module 'builtins' (built-in)>, '__name__': '__main__', '__loader__': <class '_frozen_importlib.BuiltinImporter'>}

拓展阅读

locals()