目录

  • 一.Python help 函数简介
  • 二.Python help 函数使用
    • 1.查看内置函数的帮助信息
    • 2.查看数据类型的帮助信息
  • 三.猜你喜欢

基础 Python 学习路线推荐 : Python 学习目录 >> Python 基础入门

Python 3.x 版本虽然比 2.x 少了一些内置函数,但是 **Python 内置 **函数没有 60 个,也有 40 个,那么多内置函数你记得过来吗?为了方便使用,Python 提供了help 函数专门用来提供查看函数或模块用途的详细说明;

一.Python help 函数简介

'''
参数:object – 对象/函数名/模块;返回值 – 返回对象的帮助信息;
'''
help([object])

二.Python help 函数使用

1.查看内置函数的帮助信息

# !usr/bin/env python
# !usr/bin/env python
# -*- coding:utf-8 _*-
"""
@Author:猿说编程
@Blog(个人博客地址): www.codersrc.com
@File:Python help 函数.py
@Time:2021/05/11 07:37
@Motto:不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!"""print(help(type)) # 内置函数type  - 获取数据变量类型'''
输出结果:Help on class type in module builtins:class type(object)|  type(object_or_name, bases, dict)|  type(object) -> the object's type|  type(name, bases, dict) -> a new type||  Methods defined here:||  __call__(self, /, *args, **kwargs)|      Call self as a function.||  __delattr__(self, name, /)|      Implement delattr(self, name).||  __dir__(...)|      __dir__() -> list|      specialized __dir__ implementation for types||  __getattribute__(self, name, /)|      Return getattr(self, name).||  __init__(self, /, *args, **kwargs)|      Initialize self.  See help(type(self)) for accurate signature.||  __instancecheck__(...)|      __instancecheck__() -> bool|      check if an object is an instance||  __new__(*args, **kwargs)|      Create and return a new object.  See help(type) for accurate signature.||  __prepare__(...)|      __prepare__() -> dict|      used to create the namespace for the class statement||  __repr__(self, /)|      Return repr(self).||  __setattr__(self, name, value, /)|      Implement setattr(self, name, value).||  __sizeof__(...)|      __sizeof__() -> int|      return memory consumption of the type object||  __subclasscheck__(...)|      __subclasscheck__() -> bool|      check if a class is a subclass||  __subclasses__(...)|      __subclasses__() -> list of immediate subclasses||  mro(...)|      mro() -> list|      return a type's method resolution order||  ----------------------------------------------------------------------|  Data descriptors defined here:||  __abstractmethods__||  __dict__||  __text_signature__||  ----------------------------------------------------------------------|  Data and other attributes defined here:||  __base__ = <class 'object'>|      The most base type||  __bases__ = (<class 'object'>,)||  __basicsize__ = 864||  __dictoffset__ = 264||  __flags__ = -2146675712||  __itemsize__ = 40||  __mro__ = (<class 'type'>, <class 'object'>)||  __weakrefoffset__ = 368NoneProcess finished with exit code 0
'''

2.查看数据类型的帮助信息

# !usr/bin/env python
# !usr/bin/env python
# -*- coding:utf-8 _*-
"""
@Author:猿说编程
@Blog(个人博客地址): www.codersrc.com
@File:Python help 函数.py
@Time:2021/05/11 07:37
@Motto:不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!"""print(help(str))  # 内置数据变量类型 - 字符'''
输出结果:Help on class str in module builtins:class str(object)|  str(object='') -> str|  str(bytes_or_buffer[, encoding[, errors]]) -> str||  Create a new string object from the given object. If encoding or|  errors is specified, then the object must expose a data buffer|  that will be decoded using the given encoding and error handler.|  Otherwise, returns the result of object.__str__() (if defined)|  or repr(object).|  encoding defaults to sys.getdefaultencoding().|  errors defaults to 'strict'.||  Methods defined here:||  __add__(self, value, /)|      Return self+value.||  __contains__(self, key, /)|      Return key in self.||  __eq__(self, value, /)|      Return self==value.||  __format__(...)|      S.__format__(format_spec) -> str||      Return a formatted version of S as described by format_spec.||  __ge__(self, value, /)|      Return self>=value.||  __getattribute__(self, name, /)|      Return getattr(self, name).||  __getitem__(self, key, /)|      Return self[key].||  __getnewargs__(...)||  __gt__(self, value, /)|      Return self>value.||  __hash__(self, /)|      Return hash(self).||  __iter__(self, /)|      Implement iter(self).||  __le__(self, value, /)|      Return self<=value.||  __len__(self, /)|      Return len(self).||  __lt__(self, value, /)|      Return self<value.||  __mod__(self, value, /)|      Return self%value.||  __mul__(self, value, /)|      Return self*value.n||  __ne__(self, value, /)|      Return self!=value.||  __new__(*args, **kwargs) from builtins.type|      Create and return a new object.  See help(type) for accurate signature.||  __repr__(self, /)|      Return repr(self).||  __rmod__(self, value, /)|      Return value%self.||  __rmul__(self, value, /)|      Return self*value.||  __sizeof__(...)|      S.__sizeof__() -> size of S in memory, in bytes||  __str__(self, /)|      Return str(self).||  capitalize(...)|      S.capitalize() -> str||      Return a capitalized version of S, i.e. make the first character|      have upper case and the rest lower case.||  casefold(...)|      S.casefold() -> str||      Return a version of S suitable for caseless comparisons.||  center(...)|      S.center(width[, fillchar]) -> str||      Return S centered in a string of length width. Padding is|      done using the specified fill character (default is a space)||  count(...)|      S.count(sub[, start[, end]]) -> int||      Return the number of non-overlapping occurrences of substring sub in|      string S[start:end].  Optional arguments start and end are|      interpreted as in slice notation.||  encode(...)|      S.encode(encoding='utf-8', errors='strict') -> bytes||      Encode S using the codec registered for encoding. Default encoding|      is 'utf-8'. errors may be given to set a different error|      handling scheme. Default is 'strict' meaning that encoding errors raise|      a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and|      'xmlcharrefreplace' as well as any other name registered with|      codecs.register_error that can handle UnicodeEncodeErrors.||  endswith(...)|      S.endswith(suffix[, start[, end]]) -> bool||      Return True if S ends with the specified suffix, False otherwise.|      With optional start, test S beginning at that position.|      With optional end, stop comparing S at that position.|      suffix can also be a tuple of strings to try.||  expandtabs(...)|      S.expandtabs(tabsize=8) -> str||      Return a copy of S where all tab characters are expanded using spaces.|      If tabsize is not given, a tab size of 8 characters is assumed.||  find(...)|      S.find(sub[, start[, end]]) -> int||      Return the lowest index in S where substring sub is found,|      such that sub is contained within S[start:end].  Optional|      arguments start and end are interpreted as in slice notation.||      Return -1 on failure.||  format(...)|      S.format(*args, **kwargs) -> str||      Return a formatted version of S, using substitutions from args and kwargs.|      The substitutions are identified by braces ('{' and '}').||  format_map(...)|      S.format_map(mapping) -> str||      Return a formatted version of S, using substitutions from mapping.|      The substitutions are identified by braces ('{' and '}').||  index(...)|      S.index(sub[, start[, end]]) -> int||      Return the lowest index in S where substring sub is found,|      such that sub is contained within S[start:end].  Optional|      arguments start and end are interpreted as in slice notation.||      Raises ValueError when the substring is not found.||  isalnum(...)|      S.isalnum() -> bool||      Return True if all characters in S are alphanumeric|      and there is at least one character in S, False otherwise.||  isalpha(...)|      S.isalpha() -> bool||      Return True if all characters in S are alphabetic|      and there is at least one character in S, False otherwise.||  isdecimal(...)|      S.isdecimal() -> bool||      Return True if there are only decimal characters in S,|      False otherwise.||  isdigit(...)|      S.isdigit() -> bool||      Return True if all characters in S are digits|      and there is at least one character in S, False otherwise.||  isidentifier(...)|      S.isidentifier() -> bool||      Return True if S is a valid identifier according|      to the language definition.||      Use keyword.iskeyword() to test for reserved identifiers|      such as "def" and "class".||  islower(...)|      S.islower() -> bool||      Return True if all cased characters in S are lowercase and there is|      at least one cased character in S, False otherwise.||  isnumeric(...)|      S.isnumeric() -> bool||      Return True if there are only numeric characters in S,|      False otherwise.||  isprintable(...)|      S.isprintable() -> bool||      Return True if all characters in S are considered|      printable in repr() or S is empty, False otherwise.||  isspace(...)|      S.isspace() -> bool||      Return True if all characters in S are whitespace|      and there is at least one character in S, False otherwise.||  istitle(...)|      S.istitle() -> bool||      Return True if S is a titlecased string and there is at least one|      character in S, i.e. upper- and titlecase characters may only|      follow uncased characters and lowercase characters only cased ones.|      Return False otherwise.||  isupper(...)|      S.isupper() -> bool||      Return True if all cased characters in S are uppercase and there is|      at least one cased character in S, False otherwise.||  join(...)|      S.join(iterable) -> str||      Return a string which is the concatenation of the strings in the|      iterable.  The separator between elements is S.||  ljust(...)|      S.ljust(width[, fillchar]) -> str||      Return S left-justified in a Unicode string of length width. Padding is|      done using the specified fill character (default is a space).||  lower(...)|      S.lower() -> str||      Return a copy of the string S converted to lowercase.||  lstrip(...)|      S.lstrip([chars]) -> str||      Return a copy of the string S with leading whitespace removed.|      If chars is given and not None, remove characters in chars instead.||  partition(...)|      S.partition(sep) -> (head, sep, tail)||      Search for the separator sep in S, and return the part before it,|      the separator itself, and the part after it.  If the separator is not|      found, return S and two empty strings.||  replace(...)|      S.replace(old, new[, count]) -> str||      Return a copy of S with all occurrences of substring|      old replaced by new.  If the optional argument count is|      given, only the first count occurrences are replaced.||  rfind(...)|      S.rfind(sub[, start[, end]]) -> int||      Return the highest index in S where substring sub is found,|      such that sub is contained within S[start:end].  Optional|      arguments start and end are interpreted as in slice notation.||      Return -1 on failure.||  rindex(...)|      S.rindex(sub[, start[, end]]) -> int||      Return the highest index in S where substring sub is found,|      such that sub is contained within S[start:end].  Optional|      arguments start and end are interpreted as in slice notation.||      Raises ValueError when the substring is not found.||  rjust(...)|      S.rjust(width[, fillchar]) -> str||      Return S right-justified in a string of length width. Padding is|      done using the specified fill character (default is a space).||  rpartition(...)|      S.rpartition(sep) -> (head, sep, tail)||      Search for the separator sep in S, starting at the end of S, and return|      the part before it, the separator itself, and the part after it.  If the|      separator is not found, return two empty strings and S.||  rsplit(...)|      S.rsplit(sep=None, maxsplit=-1) -> list of strings||      Return a list of the words in S, using sep as the|      delimiter string, starting at the end of the string and|      working to the front.  If maxsplit is given, at most maxsplit|      splits are done. If sep is not specified, any whitespace string|      is a separator.||  rstrip(...)|      S.rstrip([chars]) -> str||      Return a copy of the string S with trailing whitespace removed.|      If chars is given and not None, remove characters in chars instead.||  split(...)|      S.split(sep=None, maxsplit=-1) -> list of strings||      Return a list of the words in S, using sep as the|      delimiter string.  If maxsplit is given, at most maxsplit|      splits are done. If sep is not specified or is None, any|      whitespace string is a separator and empty strings are|      removed from the result.||  splitlines(...)|      S.splitlines([keepends]) -> list of strings||      Return a list of the lines in S, breaking at line boundaries.|      Line breaks are not included in the resulting list unless keepends|      is given and true.||  startswith(...)|      S.startswith(prefix[, start[, end]]) -> bool||      Return True if S starts with the specified prefix, False otherwise.|      With optional start, test S beginning at that position.|      With optional end, stop comparing S at that position.|      prefix can also be a tuple of strings to try.||  strip(...)|      S.strip([chars]) -> str||      Return a copy of the string S with leading and trailing|      whitespace removed.|      If chars is given and not None, remove characters in chars instead.||  swapcase(...)|      S.swapcase() -> str||      Return a copy of S with uppercase characters converted to lowercase|      and vice versa.||  title(...)|      S.title() -> str||      Return a titlecased version of S, i.e. words start with title case|      characters, all remaining cased characters have lower case.||  translate(...)|      S.translate(table) -> str||      Return a copy of the string S in which each character has been mapped|      through the given translation table. The table must implement|      lookup/indexing via __getitem__, for instance a dictionary or list,|      mapping Unicode ordinals to Unicode ordinals, strings, or None. If|      this operation raises LookupError, the character is left untouched.|      Characters mapped to None are deleted.||  upper(...)|      S.upper() -> str||      Return a copy of S converted to uppercase.||  zfill(...)|      S.zfill(width) -> str||      Pad a numeric string S with zeros on the left, to fill a field|      of the specified width. The string S is never truncated.||  ----------------------------------------------------------------------|  Static methods defined here:||  maketrans(x, y=None, z=None, /)|      Return a translation table usable for str.translate().||      If there is only one argument, it must be a dictionary mapping Unicode|      ordinals (integers) or characters to Unicode ordinals, strings or None.|      Character keys will be then converted to ordinals.|      If there are two arguments, they must be strings of equal length, and|      in the resulting dictionary, each character in x will be mapped to the|      character at the same position in y. If there is a third argument, it|      must be a string, whose characters will be mapped to None in the result.None
-10Process finished with exit code 0
'''

三.猜你喜欢

  1. Python 条件推导式
  2. Python 列表推导式
  3. Python 字典推导式
  4. Python 不定长参数 *argc/**kargcs
  5. Python 匿名函数 lambda
  6. Python return 逻辑判断表达式
  7. Python is 和 == 区别
  8. Python 可变数据类型和不可变数据类型
  9. Python 浅拷贝和深拷贝
  10. Python 异常处理
  11. Python 线程创建和传参
  12. Python 线程互斥锁 Lock
  13. Python 线程时间 Event
  14. Python 线程条件变量 Condition
  15. Python 线程定时器 Timer
  16. Python 线程信号量 Semaphore
  17. Python 线程障碍对象 Barrier
  18. Python 线程队列 Queue – FIFO
  19. Python 线程队列 LifoQueue – LIFO
  20. Python 线程优先队列 PriorityQueue
  21. Python 线程池 ThreadPoolExecutor(一)
  22. Python 线程池 ThreadPoolExecutor(二)
  23. Python 进程 Process 模块
  24. Python 进程 Process 与线程 threading 区别
  25. Python 进程间通信 Queue / Pipe
  26. Python 进程池 multiprocessing.Pool
  27. Python GIL 锁

未经允许不得转载:猿说编程 » Python help 函数

Python help 函数 - Python零基础入门教程相关推荐

  1. Python return逻辑判断表达式 - 零基础入门教程

    目录 一.return 逻辑判断表达式 and 二.return 逻辑判断表达式 or 三.return 逻辑判断表达式 and 和 or 配合使用 四.return 逻辑判断表达式重点总结 五.猜你 ...

  2. python怎么输出浮点数_python 零基础入门教程第 2 章:基本数据类型 (一)

    一.什么是数据类型 编程语言通过一些复杂的计算机物理底层机制,创造不同类型的数据,用来表示现实世界中的不同信息,以便于计算机更好的存储和计算. 每种编程语言都会有一些基本的数据类型用来表示现实世界中的 ...

  3. 视频教程-Python零基础入门教程-Python

    Python零基础入门教程 从2012年从事互联网至今有7年软件编程经验,曾任职国内北京互联网公司,中南林业大学授课Python 现任逻辑教育Python课程负责人,精通Python语言,精通人工智能 ...

  4. Python零基础入门教程( 快速入门)

    前言 学无止境,无止境学. 今天要给大家分享的是<Python零基础入门教程01 快速入门>,这是一个系列的教程,从零基础到项目实战.在本教程中,我会给大家介绍Python入门的一些基础知 ...

  5. Python 3.X 完全零基础入门精讲 全套视频教程

    简介 零基础小白快速学程序员大爱语言――Python,易学易用易就业!!! 目标人群:熟悉电脑基本操作,编程零基础或已具备Python或其它编程语言的人群. 课程目标:绝对零基础Python3.x 入 ...

  6. python是什么软件-零基础入门Python怎么学习?老男孩python用什么软件

    在培训学习Python时,怎么才能学好Python?随着Python技术的发展,越来越多的人开始学习Python编程语言,那么零基础入门Python该怎么学习? 1.要养成良好的代码编写习惯,注重细节 ...

  7. C语言 const 修饰函数参数 - C语言零基础入门教程

    C语言 const 修饰函数参数 - C语言零基础入门教程 目录 一.const 简介 1.const 修饰变量 2.const 修饰指针 3.const 修饰在函数名前面 4.const 修饰在函数 ...

  8. 视频教程-ARDUINO零基础入门教程【代码编程篇】-Arduino

    ARDUINO零基础入门教程[代码编程篇] 精通各种单片机编程,有十年以上ARDUINO,51单片机/STM32/PIC/AVR编程,硬件设计,绘图,编程经验.熟悉各种常用传感器使用和物联网通讯 赵勇 ...

  9. C++零基础入门教程:基础篇(一)

    前言 嘿嘿,我叕来啦─=≡Σ(((つ•̀ω•́)つ!别问我为什么突然变成了零基础入门教程(一),因为前面那三篇都是基础的不能在基础的教程了.(其实是因为顺序乱了,而且那时候没有单独弄一个专栏,后面我会 ...

  10. SEO零基础入门教程(外链的发布和软文编写)

    seo的作用是众所周知的,对网站进行seo优化,可以给网站带来大量的搜索引擎流量.但是想要做好网站优化也有难度,尤其是对于seo新手来说,因为缺乏理论和实战,所以seo新手需要多加练习.那么具体seo ...

最新文章

  1. 如果中国要做自己的GPT-3,一定离不开这家公司的算力
  2. Struts 2的输入校验(二)
  3. 调查发现 Java 和 JavaScript 是企业开发的顶级语言
  4. 【代码笔记】iOS-点击城市中的tableView跳转到旅游景点的tableView,下面会有“显示”更多。...
  5. 邮政管理部门发话:未获用户同意投放快递柜属违法行为
  6. day02-虚拟环境安装
  7. Qt4_子类化QTableWidget
  8. 前端工具,网址推荐,方便开发,学习。
  9. OpenCV2:幼儿园篇 第八章 视频操作
  10. 报考PMP一定得经过培训机构吗?
  11. cad帧数测试软件,怎样让cad运行速度更快_cad如何设置运行更流畅
  12. html留言页面设计,html的留言板制作(js)
  13. Linux常用图片查看处理软件
  14. DL2 - Improving Deep Neural Networks- Hyperparameter tuning, Regularization and Optimization
  15. 淘宝/天猫图片识别商品接口,1688图片识别商品API接口
  16. 利用javadoc制作API文档
  17. 微信小程序入门教程学习笔记
  18. 虚拟化1-创建虚拟机
  19. 阿里云的免费云虚拟主机
  20. 微信小程序、app集成微信支付

热门文章

  1. 阿里云RDS深度定制-XA Crash Safe
  2. SLS控制台内嵌操作指南
  3. MaxCompute Spark 使用和常见问题
  4. QCon演讲|闲鱼从零到千万DAU的应用架构演进
  5. 深度学习之优化详解:batch normalization
  6. CSDN 十大技术主题盘点-云原生篇
  7. 华为彭松:基于C.A.F模型构建联接竞争力,创造新增长
  8. “解救”外卖骑手,美团首次公开算法规则!
  9. python sqlite3事务_python使用上下文管理器实现sqlite3事务机制
  10. dataframe iloc_如何使用iloc和loc 对Pandas Dataframe进行索引和切片