码迷,mamicode.com
首页 > 编程语言 > 详细

python之函数用法globals()

时间:2015-11-07 23:06:28      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:

# -*- 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__‘: "\nglobals(...)\n    globals() -> dictionary\n    \n    Return the dictionary containing the current scope‘s global variables.\n"
}
‘‘‘

 

python之函数用法globals()

标签:

原文地址:http://www.cnblogs.com/dengyg200891/p/4946182.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!