python之函数用法globals()

# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#python之函数用法globals()


#globals()
#说明:在当前作用域下,查看全局变量
'''
globals(...)
    globals() -> dictionary
    
    Return the dictionary containing the current scope's global variables.
'''


#案例
b='xiaodeng'
print globals#<built-in function globals>
print globals()
'''
{
'b': 'xiaodeng',
'__builtins__': <module '__builtin__' (built-in)>,
'__file__': 'C:\Users\Administrator\Desktop\Test\Test.py',
'__package__': None,
'__name__': '__main__',
'__doc__': "
globals(...)
    globals() -> dictionary
    
    Return the dictionary containing the current scope's global variables.
"
}
'''
原文地址:https://www.cnblogs.com/dengyg200891/p/4946182.html