python dir()内建函数
2016-07-22 16:51
387 查看
在python集成开发环境中,了解内建函数dir的属性内容及其类型,同时输出它的文档字符串内容。
<built-in function dir>
['In', 'Out', '_', '__', '___', '__builtin__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_dh', '_i', '_i1', '_i10', '_i11', '_i2', '_i3', '_i4', '_i5', '_i6', '_i7', '_i8', '_i9', '_ih', '_ii', '_iii', '_oh', '_sh', 'a', 'aver', 'b',
'de', 'exit', 'flag', 'get_ipython', 'i', 'num', 'pystr', 'quit', 's']
<type 'builtin_function_or_method'>
dir([object]) -> list of strings
If called without an argument, return the names in the current scope.
Else, return an alphabetized list of names comprising (some of) the attributes
of the given object, and of attributes reachable from it.
If the object supplies a method named __dir__, it will be used; otherwise
the default dir() logic is used and returns:
for a module object: the module's attributes.
for a class object: its attributes, and recursively the attributes
of its bases.
for any other object: its attributes, its class's attributes, and
recursively the attributes of its class's base classes.
可以看到dir是内建函数名,它的类型是内建函数或者方法。通过文档字符串,可以了解它的功能。
print dir print dir() print type(dir) print dir.__doc__下面是它的输出:
<built-in function dir>
['In', 'Out', '_', '__', '___', '__builtin__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_dh', '_i', '_i1', '_i10', '_i11', '_i2', '_i3', '_i4', '_i5', '_i6', '_i7', '_i8', '_i9', '_ih', '_ii', '_iii', '_oh', '_sh', 'a', 'aver', 'b',
'de', 'exit', 'flag', 'get_ipython', 'i', 'num', 'pystr', 'quit', 's']
<type 'builtin_function_or_method'>
dir([object]) -> list of strings
If called without an argument, return the names in the current scope.
Else, return an alphabetized list of names comprising (some of) the attributes
of the given object, and of attributes reachable from it.
If the object supplies a method named __dir__, it will be used; otherwise
the default dir() logic is used and returns:
for a module object: the module's attributes.
for a class object: its attributes, and recursively the attributes
of its bases.
for any other object: its attributes, its class's attributes, and
recursively the attributes of its class's base classes.
可以看到dir是内建函数名,它的类型是内建函数或者方法。通过文档字符串,可以了解它的功能。
相关文章推荐
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- install and upgrade scrapy
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- Python中zip()函数用法举例
- Python中map()函数浅析
- Python将excel导入到mysql中
- Python在CAM软件Genesis2000中的应用
- 使用Shiboken为C++和Qt库创建Python绑定
- FREEBASIC 编译可被python调用的dll函数示例
- Python 七步捉虫法