Python 的 help 函数使用_后端开发

Python 的 help 函数使用_后端开发,第1张

Python 如何自定义模块?_后端开发

在本篇文章里小编给大家分享了关于Python中添加自定义模块的实例方法,需要的朋友们可以学习下。


Python 的 help 函数使用_后端开发,第2张

help函数是python的一个内置函数,在python基础知识中介绍过什么是内置函数,它是python自带的函数,任何时候都可以被使。


help函数能作什么、怎么使用help函数查看python模块学习中函数的用法,和使用help函数时需要注意哪些问题,下面来简单的说一下。


help函数能作什么

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


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


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

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


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

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

1、查看一个模块的帮助

CentOS安装PHP7的正确方法_后端开发

CentOS上的PHP版本都十分古老,满足不了一些框架对PHP版本的要求。


于是,出现了许多第三方软件库,如EPEL、RPM Fusion、Remi等,这些库提供了新版的PHP。


让我们的系统能与时俱进。


>>>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教程》

以上就是Python 的 help 函数使用的详细内容,更多请关注ki4网其它相关文章!

Go Wails 框架构建桌面应用示例_后端开发

这篇文章主要介绍了利用Go Wails 框架构建桌面应用示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/zaji/560851.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2020-06-24
下一篇 2020-06-24

发表评论

登录后才能评论

评论列表(0条)

保存