当前位置: 首页 > 图灵资讯 > 行业资讯> python globals函数是什么?

python globals函数是什么?

发布时间:2024-10-09 14:07:52

2.参数

3.返回值

回到字典的全局变量。

4.实例

outerVar="thisisaglobalvariable"

print("glocalvariables:")
print(globals())
-----
glocalvariables:
{'__name__':'__main__','__doc__':None,'__package__':None,'__loader__':<_frozen_importlib_external.Sourcefilelelelelelerobectat0000028FD1CF8>,'__spec__':None,'__annotations__':{},'__builtins__':<module'builtins'(built-in)>,'__file__':'C:/Users/szdjy/PycharmProjects/untitled/fun.py','__cached__':None,'outerVar':'thisisaglobalvariable'}

内置函数globals()将以字典类型返回当前位置的所有全局变量(变量名:值)

以上是python globals函数基本内容的介绍,相信朋友们已经对回归全局变量字典有所了解,下一步就自己试试吧。

(推荐操作系统:windows7系统Python 3.9.1,DELL G3电脑。)

相关文章

如何让vim支持python3

如何让vim支持python3

2025-09-12
python2.7和3.6区别有哪些

python2.7和3.6区别有哪些

2025-09-12
python3有serial库吗

python3有serial库吗

2025-09-12
python中w、r表示什么意思

python中w、r表示什么意思

2025-09-12
python中如何把list变成字符串

python中如何把list变成字符串

2025-09-12
python命名空间是什么

python命名空间是什么

2025-09-12