python之函数用法locals()

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


#locals()
#说明:查找局部变量,返回一个名字/值对的字典对象。只具备查找权限
'''
locals(...)
    locals() -> dictionary
    
    Update and return a dictionary containing the current scope's local variables.
'''



#案例
def test():
    name='xiaodeng'
    version=2.7
    time='2015.11.07'
    print locals()

    
print test()#{'version': 2.7, 'name': 'xiaodeng', 'time': '2015.11.07'}
原文地址:https://www.cnblogs.com/dengyg200891/p/4945801.html