Python help 函数 - Python零基础入门教程

目录

  • 一.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 函数

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/525181.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

倒计时 2 天,2018 中国大数据技术大会(BDTC)报名通道即将关闭(附参会提醒)...

戳蓝字“CSDN云计算”关注我们哦&#xff01;2018 年12 月 6-8 日&#xff0c;由中国计算机学会主办&#xff0c;CCF大数据专家委员会承办&#xff0c;CSDN、中科天玑数据科技股份有限公司协办的 2018 中国大数据技术大会&#xff08;BDTC&#xff09;&#xff0c;携主题“大数…

运算符细节讲解

1.算数运算符&#xff0c;-&#xff0c;*&#xff0c;/&#xff0c;%&#xff0c;&#xff0c;-- 2.赋值运算符 3.关系运算符>,<,>,<,,!instanceof 4.逻辑运算符&&&#xff0c;||&#xff0c;&#xff01; package operator; ​ public class Demo01 {…

BugkuCTF-PWN题pwn5-overflow2超详细讲解

知识点 setvbuf: setvbuf函数的功能&#xff1a; 如果你的内存足够大&#xff0c;可以把文件IO的BUF设置大一些&#xff0c;这样每次你用 fopen/fread/fwrite/fscanf/fprintf语句的时候&#xff0c;都会在内存里操作&#xff0c;减少内存到磁盘IO读写的操作次数&#xff0c;提…

下载 / 安装 Visual Studio - C语言零基础入门教程

目录 一.下载 Visual Studio 1.Visual Studio 下载地址2.Visual Studio 分类3.Visual Studio 下载 二.安装 Visual Studio 1.安装虚拟光驱2.安装 VS 三.猜你喜欢 零基础 C/C 学习路线推荐 : C/C 学习目录 >> C 语言基础入门 天下武功&#xff0c;唯快不破&#xff0c;虽…

包机制、阿里巴巴开发手册

公司域名倒置作为包名 com.baidu.www 阿里巴巴开发手册可百度搜索看看

想让马云成为你的老大?揭秘阿里面试情景

戳蓝字“CSDN云计算”关注我们哦&#xff01;前言最近评论的小伙伴总是会问&#xff0c;如何面试阿里Java技术岗&#xff0c;需要什么条件&#xff0c;做哪些准备&#xff1b;小编就这些问题找到了阿里技术团队中在一线真正带Java开发团队并直接参与技术面试的专家&#xff0c;…

BugkuCTF-PWN题pwn6-printf超详细讲解(未提供Libc版本)

前言 此题是我根据某大佬wp(从Libc官网下载的Libc)解出的&#xff0c;我在他的exp脚本基础上进行修改通过LibcSearcher搜索可利用的Libc&#xff0c;因为这道题在Bugku未提供Libc版本 有些部分很难理解&#xff0c;如果有大佬知道的&#xff0c;还请不吝赐教 还是先把解题流…

安装 Visual Studio 插件 Visual Assist - C语言零基础入门教程

目录 一.下载 Visual Assist 插件二.安装 Visual Assist 插件 1.运行 VA_X_Setup2270_0.exe2.激活插件3.重启 Visual Studio 完成安装 三.猜你喜欢 零基础 C/C 学习路线推荐 : C/C 学习目录 >> C 语言基础入门 前一篇文章中我们已经把 Visual Studio 2015 安装 好了&…

名企程序员被裁实录:早上还在改 Bug,晚上就成下岗工

戳蓝字“CSDN云计算”关注我们哦&#xff01;尽管最近新闻铺天盖地的“寒冬说”&#xff0c;由于我多年身处在稳定的大公司里&#xff0c;并没有太多的危机感。昨天大伙一起讨论年会表演什么节目&#xff0c;你演宁采臣&#xff0c;他男扮女装演小倩&#xff0c;大胖就演宁采臣…

BugkuCTF-PWN题pwn7-repeater详细讲解多解法

知识点 解题流程 方法一 查看文件类型&#xff1a; 32位文件 查看保护机制 只开启了NX 32位IDA打开 伪码&#xff1a; 0x70112 0x64100 发现该题目为典型的格式字符串漏洞。 解题思路 此题的大概思路如下&#xff1a; 1、找到libc_start_main在栈内的偏移&#xff0c;…

设置 Visual Studio 文件版权信息 - C语言零基础入门教程

目录 一.手动修改原始代码模板二.通过插件 Visual Assist 设置版权信息 1.安装插件 Visual Assist2.打开 VS&#xff0c;找到 VAssistX 选项3.设置模板内容4.点击 OK&#xff0c;设置完成 三.猜你喜欢 零基础 C/C 学习路线推荐 : C/C 学习目录 >> C 语言基础入门 写代码…

流程控制详解

Scanner对象&#xff1a;java5新特性&#xff0c;获取用户输入 语法&#xff1a;Scanner snew Scanner&#xff08;System.in&#xff09;; next()和nextLine()获取输入&#xff0c;hasNext()和hasNextLine()判断是否还有输入数据 example&#xff1a; package com.wuming.s…

HR怒甩程序员男友:不加班没上进没前途,网友:惹不起

戳蓝字“CSDN云计算”关注我们哦&#xff01;对于程序员来说&#xff0c;加班就是家常便饭&#xff0c;但也有特例&#xff0c;最近就有为女 HR 在某论坛吐槽&#xff1a;最近和一个程序员谈恋爱&#xff0c;只持续三天就把程序员甩了&#xff0c;原因是男朋友每天六点下班&…

BugkuCTF-Crypto题rsa

解题流程 n&#xff0c;e已经给出&#xff0c;可以看出e特别大&#xff0c;在e特别大的情况下&#xff0c;可以使用wiener attack的方法进行破解&#xff0c;正好工具RsaCtfTool集成了wiener attack的方法&#xff0c;所以可以直接使用RsaCtfTool计算私钥。 典型的rsa… 密钥的…

Visual Studio 2008 完全卸载 - C语言零基础入门教程

目录 一.VS2008 卸载方式一 (不推荐)二.VS2008 卸载方式一 ( 推荐)三.猜你喜欢 零基础 C/C 学习路线推荐 : C/C 学习目录 >> C 语言基础入门 Visual Studio 已经更新到 2019&#xff0c;可能部分公司为了保证代码的兼容性&#xff0c;还是在使用比较老的 2005 或者 2008…

Scanner进阶详细讲解

package com.wuming.scanner; import java.util.Scanner; public class Demo04 { public static void main(String[] args) { Scanner scanner new Scanner(System.in); int i0; float f0.0f; System.out.println("请输入整数&…

相亲网站比自己优秀的男人太多?单身程序员惊现神操作!

戳蓝字“CSDN云计算”关注我们哦&#xff01;话说&#xff0c;今年还有不到一个月就要过去了&#xff0c;作为一个单身狗的小编&#xff0c;看着大街上一个个成双成对的情侣&#xff0c;不由感到悲从心来&#xff0c;只能妄图从新闻中寻找一丝安慰。结果你别说&#xff0c;我最…

BugkuCTF-Crypto题给你私钥吧

方法一 用 RsaCtfTool这个脚本工具。。。然后python RsaCtfTool.py --publickey pubkey.pem --uncipherfile flag.enc直接用公钥进行攻击解密 方法二 思路&#xff1a;高位攻击还原pq&#xff0c;然后生成密钥进行解密 分三步&#xff1a; 3.第三步通过私钥文件OAEP解密…

Visual Studio 2013 / 2015 完全卸载 - C语言零基础入门教程

目录 一.查找 vs_community.exe 文件二.以管理身份打开 cmd 窗口三.使用微软官方的卸载工具来清理残余数据 1.下载清理工具2.以管理员身份执行 setup.forceduninstall.exe&#xff1b;3.按 Y 进行卸载&#xff1b; 四猜你喜欢 零基础 C/C 学习路线推荐 : C/C 学习目录 >>…

顺序结构讲解

定义&#xff1a;按顺序执行 package com.wuming.struct; public class ShunXuDemo { public static void main(String[] args) { System.out.println("hello1"); System.out.println("hello2"); System.out.println("…