>>> a="1"
>>> b="a"
>>> print(a,b)
1 a
>>> print(a,locals()[b])
1 1
>>>
locals() 函数会以字典类型返回当前位置的全部局部变量。
>>> print(locals())
{'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__':
>>> print(locals()[b]) #当函数后面指定相应的变量则显示指定内存的变量
1
>>>
>>> print(locals()['__name__'])
__main__
>>> print(locals()['b'])
a
>>> print(locals()[b])
1
>>>