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'}

 

posted @ 2015-11-07 17:56  Xiao|Deng  阅读(2057)  评论(0编辑  收藏  举报