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的Pyspider为例剖析搜索引擎的网络爬虫实现方法
Mar 30 Python
python字符串编码识别模块chardet简单应用
Jun 15 Python
教你用一行Python代码实现并行任务(附代码)
Feb 02 Python
python装饰器深入学习
Apr 06 Python
tensorflow 加载部分变量的实例讲解
Jul 27 Python
python3模拟实现xshell远程执行liunx命令的方法
Jul 12 Python
python使用Pandas库提升项目的运行速度过程详解
Jul 12 Python
Django中提供的6种缓存方式详解
Aug 05 Python
Docker部署Python爬虫项目的方法步骤
Jan 19 Python
python实现企业微信定时发送文本消息的实例代码
Nov 25 Python
python中的列表和元组区别分析
Dec 30 Python
教你怎么用python selenium实现自动化测试
May 27 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 curl参数的详解
2013/06/17 PHP
用jQuery技术实现Tab页界面之二
2009/09/21 Javascript
基于jquery的时间段实现代码
2012/08/02 Javascript
js/html光标定位的实现代码
2013/09/23 Javascript
JavaScript实现的购物车效果可以运用在好多地方
2014/05/09 Javascript
省市选择的简单实现(基于zepto.js)
2016/06/21 Javascript
CentOS 安装NodeJS V8.0.0的方法
2017/06/15 NodeJs
NodeJS实现图片上传代码(Express)
2017/06/30 NodeJs
JS+canvas动态绘制饼图的方法示例
2017/09/12 Javascript
关于vue中watch检测到不到对象属性的变化的解决方法
2018/02/08 Javascript
vue.js实现双击放大预览功能
2020/06/23 Javascript
vue实现列表滚动的过渡动画
2020/06/29 Javascript
Vue使用screenfull实现全屏效果
2020/09/17 Javascript
[39:53]完美世界DOTA2联赛PWL S2 LBZS vs Forest 第一场 11.19
2020/11/19 DOTA
Python中计算三角函数之cos()方法的使用简介
2015/05/15 Python
Python 对输入的数字进行排序的方法
2018/06/23 Python
Python3标准库总结
2019/02/19 Python
Python中模块(Module)和包(Package)的区别详解
2019/08/07 Python
pygame实现俄罗斯方块游戏(AI篇1)
2019/10/29 Python
使用python自动追踪你的快递(物流推送邮箱)
2020/03/17 Python
Python3.9 beta2版本发布了,看看这7个新的PEP都是什么
2020/06/10 Python
html5中的input新属性range使用记录
2014/09/05 HTML / CSS
FILA斐乐中国官方商城:意大利运动品牌
2017/01/25 全球购物
澳大利亚领先的美容护肤品零售商之一:SkincareStore
2018/01/22 全球购物
中国梦口号
2014/06/13 职场文书
红领巾心向党演讲稿
2014/09/10 职场文书
县政府领导班子四风问题对照检查材料思想汇报
2014/09/26 职场文书
班子成员四风问题自我剖析材料
2014/09/29 职场文书
中班下学期个人工作总结
2015/02/12 职场文书
幼儿园个人总结
2015/02/28 职场文书
2015年电话客服工作总结
2015/05/18 职场文书
员工手册董事长致辞
2015/07/29 职场文书
音乐课《小猫钓鱼》教学反思
2016/02/18 职场文书
Python编程根据字典列表相同键的值进行合并
2021/10/05 Python
APP界面设计技巧和注意事项
2022/04/29 杂记
python实现学员管理系统(面向对象版)
2022/06/05 Python