python的help函数如何使用


Posted in Python onJune 11, 2020

help函数是python的一个内置函数,在python基础知识中介绍过什么是内置函数,它是python自带的函数,任何时候都可以被使。help函数能作什么、怎么使用help函数查看python模块学习中函数的用法,和使用help函数时需要注意哪些问题,下面来简单的说一下。

help函数能作什么

在使用python来编写代码时,会经常使用python调用函数、自带函数或模块,一些不常用的函数或是模块的用途不是很清楚,这时候就需要用到help函数来查看帮助。

这里要注意下,help()函数是查看函数或模块用途的详细说明,而dir()函数是查看函数或模块内的操作方法都有什么,输出的是方法列表。

怎么使用help函数查看python模块中函数的用法

help( )括号内填写参数,操作方法很简单。

使用help函数查看帮助时需要注意哪些问题

在写help()函数使用方法时说过,括号中填写参数,那在这里要注意参数的形式:

1、查看一个模块的帮助

>>>help('sys')

之后它回打开这个模块的帮助文档

2、查看一个数据类型的帮助

>>>help('str')

返回字符串的方法及详细说明

>>>a = [1,2,3]
>>>help(a)

这时help(a)则会打开list的操作方法

>>>help(a.append)

会显示list的append方法的帮助。

实例扩展:

怎么使用help函数查看python模块中函数的用法

help()括号内填写参数,操作方法很简单。例如:

>>> help('dir')
Help on built-in function dir in module builtins:
dir(...)
  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 attribut
es
  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.

到此这篇关于python的help函数如何使用的文章就介绍到这了,更多相关如何使用python的help函数内容请搜索三水点靠木以前的文章或继续浏览下面的相关文章希望大家以后多多支持三水点靠木!

Python 相关文章推荐
python实现的一个p2p文件传输实例
Jun 04 Python
Python实现的批量下载RFC文档
Mar 10 Python
matplotlib绘制动画代码示例
Jan 02 Python
通过Python 接口使用OpenCV的方法
Apr 02 Python
详解Python if-elif-else知识点
Jun 11 Python
python接口自动化(十六)--参数关联接口后传(详解)
Apr 16 Python
flask框架json数据的拿取和返回操作示例
Nov 28 Python
Python之字典对象的几种创建方法
Sep 30 Python
python基于exchange函数发送邮件过程详解
Nov 06 Python
python实现图像高斯金字塔的示例代码
Dec 11 Python
python热力图实现简单方法
Jan 29 Python
教你如何使用Python Tkinter库制作记事本
Jun 10 Python
新手学python应该下哪个版本
Jun 11 #Python
python开发前景如何
Jun 11 #Python
python编写softmax函数、交叉熵函数实例
Jun 11 #Python
python能开发游戏吗
Jun 11 #Python
使用sklearn对多分类的每个类别进行指标评价操作
Jun 11 #Python
python属于解释语言吗
Jun 11 #Python
numpy的Fancy Indexing和array比较详解
Jun 11 #Python
You might like
PHP日期时间函数的高级应用技巧
2009/05/16 PHP
JQuery DataTable删除行后的页面更新利用Ajax解决
2013/05/17 Javascript
将字符串中由空格隔开的每个单词首字母大写
2014/04/06 Javascript
jquery easyui 结合jsp简单展现table数据示例
2014/04/18 Javascript
jQuery实现DIV层收缩展开的方法
2015/02/27 Javascript
两行代码轻松搞定JavaScript日期验证
2016/08/03 Javascript
Js查找字符串中出现次数最多的字符及个数实例解析
2016/09/05 Javascript
jQuery实现动态添加tr到table的方法
2016/12/26 Javascript
ajax图片上传,图片异步上传,更新实例
2016/12/30 Javascript
获取IE浏览器Cookie信息的方法
2017/01/23 Javascript
AngularJS中的拦截器实例详解
2017/04/07 Javascript
jQuery实现radio第一次点击选中第二次点击取消功能
2017/05/15 jQuery
利用canvas实现的加载动画效果实例代码
2017/07/05 Javascript
Vue自定义指令详解
2017/07/28 Javascript
JavaScript实现美化滑块效果
2019/05/17 Javascript
一篇文章带你浅入webpack的DLL优化打包
2020/02/20 Javascript
Python中尝试多线程编程的一个简明例子
2015/04/07 Python
python字典键值对的添加和遍历方法
2016/09/11 Python
python妙用之编码的转换详解
2017/04/21 Python
详细分析python3的reduce函数
2017/12/05 Python
python复制列表时[:]和[::]之间有什么区别
2018/10/16 Python
Python pandas DataFrame操作的实现代码
2019/06/21 Python
python实现翻转棋游戏(othello)
2019/07/29 Python
python redis 批量设置过期key过程解析
2019/11/26 Python
python函数不定长参数使用方法解析
2019/12/14 Python
python爬虫模拟浏览器访问-User-Agent过程解析
2019/12/28 Python
flask项目集成swagger的方法
2020/12/09 Python
ALDO英国官网:加拿大女鞋品牌
2018/02/19 全球购物
美国最受欢迎的度假目的地优惠套餐:BookVIP
2018/09/27 全球购物
如何选择使用结构还是类
2014/05/30 面试题
硕士论文致谢范文
2015/05/14 职场文书
干货!开幕词的写作方法
2019/04/02 职场文书
写好求职信的技巧解密
2019/05/14 职场文书
2019最新版股权转让及委托持股协议书范本
2019/08/07 职场文书
pytorch 权重weight 与 梯度grad 可视化操作
2021/06/05 Python
Win11怎么把合并的任务栏分开 Win11任务栏合并分开教程
2022/04/06 数码科技