Python 的帮助--help、dir、type
来源:互联网 发布:unity3d animation 编辑:程序博客网 时间:2024/06/05 18:01
介绍下,查看函数或模块用途的几个函数
1.help()
作用: 用于查看函数或模块用途的详细说明
语法: help(obj)
返回值: 返回对象的帮助信息
# help('sys') # 查看 sys 模块的帮助# help('str')a=[1,2,3]#help (a) # 查看列表 list 帮助信息help (a.append) # 显示list的append方法的帮助
Help on built-in function append:append(...) L.append(object) -- append object to end2.dir()
作用:dir() 函数不带参数时,返回当前范围内的变量、方法和定义的类型列表;带参数时,返回参数的属性、方法列表。如果参数包含方法__dir__(),该方法将被调用。如果参数不包含__dir__(),该方法将最大限度地收集参数信息。
语法:dir(obj)
返回值:返回模块的属性列表
print dir([])
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']3. type()
作用:只有第一个参数则返回对象的类型,三个参数返回新的类型对象。
语法: class type(name ,bases,dict)
name-类名
bases--元组
dict--字典,类内定义的命名空间变量
返回值:返回参数对象类型
python 的所有数据类型都是类,可以通过 type() 查看该变量的数据类型:
print type(1)print type('aaaa')print type([2])print type({'aa':10})
<type 'int'><type 'str'><type 'list'><type 'dict'>
阅读全文
0 0
- Python 的帮助--help、dir、type
- 用好Python帮助函数help(),dir(),type()
- python中3个帮助函数help,dir,type的使用
- Python 寻求帮助dir,help
- Python函数---dir(),help(),type()
- Python中有用的三个工具:dir, type和help
- Python 查看帮助文档 dir(),help()
- python文档帮助help()和dir()
- 在命令行中查看python帮助文档 --dir、help、__doc__
- Python中help() 与 dir()
- 如何在命令行模式下查看Python帮助文档---dir、help、__doc__
- 如何在命令行模式下查看Python帮助文档---dir、help、__doc__
- 如何在命令行模式下查看Python帮助文档---dir、help、__doc__
- 在命令行模式下查看Python帮助文档---dir、help、__doc__
- python help获取帮助
- Python的type, str, dir和callable函数
- Python查看帮助---help函数
- Python查看帮助---help函数
- Cocoa 哪种方式创建对象?例如NSArray
- win10安装64位Pygame
- 倍增求快速幂,乘法
- 文章标题 nginx 实现express 高并发接口
- spring StopWatch 简单便捷的计时器
- Python 的帮助--help、dir、type
- C++中的构造函数
- CAD版本转换怎么做
- Perm
- 常用效果的实现
- 让MT7620完美支持32M SPI Flash(W25Q256) — 兼谈设备驱动中的shutdown方法
- oj提交结果整理
- 云栖大会所感所想
- BaseActivity封装