help与dir与type:在使用python来编写代码时,会经常使用python自带函数或模块,一些不常用的函数或是模块的用途不是很清楚,这时候就需要用到help函数来查看帮助。
这里要注意下,help()函数是查看函数或模块用途的详细说明,而dir()函数是查看函数或模块内的操作方法都有什么,输出的是方法列表,对于函数还会输出属性。type查看变量属性

例子:a=[1,2,3,4]

help(a)显示如下:

class list(object)
| list() -> new empty list
| list(iterable) -> new list initialized from iterable's items
|
| Methods defined here:
·······
| append(...)
| L.append(object) -- append object to end
|
| count(...)
| L.count(value) -> integer -- return number of occurrences of value
|
| extend(...)
| L.extend(iterable) -- extend list by appending elements from the iterable
|
| index(...)
| L.index(value, [start, [stop]]) -> integer -- return first index of value.
| Raises ValueError if the value is not present.
|
| insert(...)
| L.insert(index, object) -- insert object before index
|
| pop(...)
| L.pop([index]) -> item -- remove and return item at index (default last).
| Raises IndexError if list is empty or index is out of range.
|
| remove(...)
| L.remove(value) -- remove first occurrence of value.
| Raises ValueError if the value is not present.
|
| reverse(...)
| L.reverse() -- reverse *IN PLACE*
|
| sort(...)
| L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
| cmp(x, y) -> -1, 0, 1
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
|
| __new__ = <built-in method __new__ of type object>
| T.__new__(S, ...) -> a new object with type S, a subtype of T

dir(a)显示如下:

['__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']

def add(x,y)

return x+y

dir(add)==》['__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__', '__doc__', '__format__', '__get__', '__getattribute__', '__globals__', '__hash__', '__init__', '__module__', '__name__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals', 'func_name']

add.func_globals==》{'__builtins__': <module '__builtin__' (built-in)>, '__file__': 'H:\\LearnPython\\\xba\xaf\xca\xfd\xb5\xc4\xca\xf4\xd0\xd4\xd3\xeb\xb2\xd9\xd7\xf7.py', '__package__': None, 'add': <function add at 0x0272F670>, '__name__': '__main__', '__doc__': None}

type(a)显示:<type 'list'>

help也可查看模块属性,只需将模块值传入,如help(string)

查看帮助文档的一些方法:help,dir,type,func_global等的更多相关文章

  1. (转)创建和查看Javadoc文档

    原地址:http://jinnaxu-tju-edu-cn.iteye.com/blog/667177 Javadoc是Sun公司提供的一个技术,它从程序源代码中抽取类.方法.成员等注释形成一个和源代 ...

  2. Java读取“桌面”、“我的文档”路径的方法

    读取“桌面”的方法: javax.swing.filechooser.FileSystemView fsv = javax.swing.filechooser.FileSystemView.getFi ...

  3. [No0000190]vim8安装教程和vim中文帮助文档Vimcdoc安装方法-Vim使用技巧(5)

    Vim8.0是近十年来的一次大更新,支持任务.异步I/O.Channels和JSON以及异步计时器.Lambdas 和 Closures等,还包括对GTK + 3的支持.由于ubuntu默认安装的Vi ...

  4. 安装的Android SDK下无doc文件夹问题 以及关联Android帮助文档和查看文档 以及查看在线文档

    参考连接:https://blog.csdn.net/fangzicheng/article/details/78344521 https://jingyan.baidu.com/article/29 ...

  5. Text文档编码识别方法

    Text文档编码识别方法 在做文档读取的时候,时常碰到编码格式不正确的问题,而要怎么样正确识别文档的编码格式,成了很多程序员的一块心病,今天我就要试着治好这块心病,这段代码的浓缩来自上千万文档的数据分 ...

  6. JavaScipt选取文档元素的方法

    摘自JavaScript权威指南(jQuery根据样式选择器查找元素的终极方式是 先用getElementsByTagName(*)获取所有DOM元素,然后根据样式选择器对所有DOM元素进行筛选) 选 ...

  7. 自动文档摘要评价方法:Edmundson,ROUGE

    自动文档摘要评价方法大致分为两类: (1)内部评价方法(Intrinsic Methods):提供参考摘要,以参考摘要为基准评价系统摘要的质量.系统摘要与参考摘要越吻合, 质量越高. (2)外部评价方 ...

  8. Redis查看帮助文档

    Redis查看帮助文档的方式,目前我用到的主要有两种: 1.访问官方文档: Redis文档 2.在redis-cli中通过命令查看,输入"?"或者"help"回 ...

  9. Effective Java 第三版——74. 文档化每个方法抛出的所有异常

    Tips 书中的源代码地址:https://github.com/jbloch/effective-java-3e-source-code 注意,书中的有些代码里方法是基于Java 9 API中的,所 ...

随机推荐

  1. SQL2008-备份SQL数据库的语句

    SQL2008:1.备份库BACKUP DATABASE CDJQ_CEM2008 TO DISK = 'd:\zhu\123.bak'2.开启RAR加压功能EXEC sp_configure 'sh ...

  2. 转载 SharePoint开发部署WSP解决方案包

    转载原出处: http://642197992.blog.51cto.com/319331/1582731 注:本文所讲内容以SharePoint2013版本为例,开发工具以VS2013为基础.历史版 ...

  3. angular的filter

    angular的filter filter两种用法 1.在模板中使用filter {{expression|filter}}//基本用法 {{expression|filter1|filter2|fi ...

  4. Oracle中遍历Ref Cursor示例

    示例编写环境 数据库:Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 登陆用户:Scott O ...

  5. cocos2d-x 纹理研究

    转自:http://blog.csdn.net/qq51931373/article/details/9119161 1.通常情况下用PVR格式的文件来进行图片显示的时候,在运行速度和内存消耗方面都要 ...

  6. [Practical Git] Switching between current branch and last checkout branch

    When working on a project, it is much easier to work on features and bugs in isolation of the rest o ...

  7. pomelo windows 安装笔记

    1.安装nodejs http://nodejs.org/download/...这个简单.. 2.下载pomelo..并且 安装所需要的包.未能加载visual c++组件 “VCBuild.exe ...

  8. C#_delegate - 用委托实现事件,Display和Log类都使用Clock对象

    //public event SecondChangeHandler OnSecondChange; 若将委托加上event,则视作是事件,不是委托,外围就不能直接对OnSecondChange传值 ...

  9. 多台Linux服务器SSH相互访问无需密码--转

    一.环境配置 1.系统:CentOS release 5.6   IP:192.168.4.200   主机名:JW01 2.系统:CentOS release 5.9   IP:192.168.4. ...

  10. Pull Requests

    Contribution Guide Issue Tracker You can find outstanding issues on the GitHub Issue Tracker. Pull R ...