首先区分python中的globals()函数与global关键字
"globals()" returns a dict with all global variables in the current scope:
>>> globals()
{...}
"locals()" does the same but for all local variables in the current scope:
>>> locals()
{...}
>>> globals()
{...}
>>> locals()
{...}
转载于:https://my.oschina.net/zho/blog/1628212