Python 批量抓取help()函数的帮助内容(附36M帮助文档)

简介: Python 批量抓取help()函数的帮助内容(附36M帮助文档)

在python提示符下,help(int)可以得到 class int 的帮助; help("math") 可以得到 built-in module math 的帮助;...等等

>>> help(int)
Help on class int in module builtins:
class int(object)
 |  int([x]) -> integer
 |  int(x, base=10) -> integer
 |  
 |  Convert a number or string to an integer, or return 0 if no arguments
 |  are given.  If x is a number, return x.__int__().  For floating point
 |  numbers, this truncates towards zero.
 |  
 |  If x is not a number or if base is given, then x must be a string,
 |  bytes, or bytearray instance representing an integer literal in the
 |  given base.  The literal can be preceded by '+' or '-' and be surrounded
 |  by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
 |  Base 0 means to interpret the base from the string as an integer literal.
 |  >>> int('0b100', base=0)
 |  4
 |  
 |  Built-in subclasses:
 |      bool
 |  
 |  Methods defined here:
 |  
 |  __abs__(self, /)
 |      abs(self)
 |  
 |  __add__(self, value, /)
 |      Return self+value.
 |  
 |  __and__(self, value, /)
 |      Return self&value.
 |  
 |  __bool__(self, /)
 |      self != 0
 |  
 |  __ceil__(...)
 |      Ceiling of an Integral returns itself.
 |  
 |  __divmod__(self, value, /)
 |      Return divmod(self, value).
 |  
 |  __eq__(self, value, /)
 |      Return self==value.
 |  
 |  __float__(self, /)
 |      float(self)
 |  
 |  __floor__(...)
 |      Flooring an Integral returns itself.
 |  
 |  __floordiv__(self, value, /)
 |      Return self//value.
 |  
 |  __format__(self, format_spec, /)
 |      Default object formatter.
 |  
 |  __ge__(self, value, /)
 |      Return self>=value.
 |  
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |  
 |  __getnewargs__(self, /)
 |  
 |  __gt__(self, value, /)
 |      Return self>value.
 |  
 |  __hash__(self, /)
 |      Return hash(self).
 |  
 |  __index__(self, /)
 |      Return self converted to an integer, if self is suitable for use as an index into a list.
 |  
 |  __int__(self, /)
 |      int(self)
 |  
 |  __invert__(self, /)
 |      ~self
 |  
 |  __le__(self, value, /)
 |      Return self<=value.
 |  
 |  __lshift__(self, value, /)
 |      Return self<<value.
 |  
 |  __lt__(self, value, /)
 |      Return self<value.
 |  
 |  __mod__(self, value, /)
 |      Return self%value.
 |  
 |  __mul__(self, value, /)
 |      Return self*value.
 |  
 |  __ne__(self, value, /)
 |      Return self!=value.
 |  
 |  __neg__(self, /)
 |      -self
 |  
 |  __or__(self, value, /)
 |      Return self|value.
 |  
 |  __pos__(self, /)
 |      +self
 |  
 |  __pow__(self, value, mod=None, /)
 |      Return pow(self, value, mod).
 |  
 |  __radd__(self, value, /)
 |      Return value+self.
 |  
 |  __rand__(self, value, /)
 |      Return value&self.
 |  
 |  __rdivmod__(self, value, /)
 |      Return divmod(value, self).
 |  
 |  __repr__(self, /)
 |      Return repr(self).
 |  
 |  __rfloordiv__(self, value, /)
 |      Return value//self.
 |  
 |  __rlshift__(self, value, /)
 |      Return value<<self.
 |  
 |  __rmod__(self, value, /)
 |      Return value%self.
 |  
 |  __rmul__(self, value, /)
 |      Return value*self.
 |  
 |  __ror__(self, value, /)
 |      Return value|self.
 |  
 |  __round__(...)
 |      Rounding an Integral returns itself.
 |      Rounding with an ndigits argument also returns an integer.
 |  
 |  __rpow__(self, value, mod=None, /)
 |      Return pow(value, self, mod).
 |  
 |  __rrshift__(self, value, /)
 |      Return value>>self.
 |  
 |  __rshift__(self, value, /)
 |      Return self>>value.
 |  
 |  __rsub__(self, value, /)
 |      Return value-self.
 |  
 |  __rtruediv__(self, value, /)
 |      Return value/self.
 |  
 |  __rxor__(self, value, /)
 |      Return value^self.
 |  
 |  __sizeof__(self, /)
 |      Returns size in memory, in bytes.
 |  
 |  __sub__(self, value, /)
 |      Return self-value.
 |  
 |  __truediv__(self, value, /)
 |      Return self/value.
 |  
 |  __trunc__(...)
 |      Truncating an Integral returns itself.
 |  
 |  __xor__(self, value, /)
 |      Return self^value.
 |  
 |  as_integer_ratio(self, /)
 |      Return integer ratio.
 |      
 |      Return a pair of integers, whose ratio is exactly equal to the original int
 |      and with a positive denominator.
 |      
 |      >>> (10).as_integer_ratio()
 |      (10, 1)
 |      >>> (-10).as_integer_ratio()
 |      (-10, 1)
 |      >>> (0).as_integer_ratio()
 |      (0, 1)
 |  
 |  bit_length(self, /)
 |      Number of bits necessary to represent self in binary.
 |      
 |      >>> bin(37)
 |      '0b100101'
 |      >>> (37).bit_length()
 |      6
 |  
 |  conjugate(...)
 |      Returns self, the complex conjugate of any int.
 |  
 |  to_bytes(self, /, length, byteorder, *, signed=False)
 |      Return an array of bytes representing an integer.
 |      
 |      length
 |        Length of bytes object to use.  An OverflowError is raised if the
 |        integer is not representable with the given number of bytes.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.
 |      signed
 |        Determines whether two's complement is used to represent the integer.
 |        If signed is False and a negative integer is given, an OverflowError
 |        is raised.
 |  
 |  ----------------------------------------------------------------------
 |  Class methods defined here:
 |  
 |  from_bytes(bytes, byteorder, *, signed=False) from builtins.type
 |      Return the integer represented by the given array of bytes.
 |      
 |      bytes
 |        Holds the array of bytes to convert.  The argument must either
 |        support the buffer protocol or be an iterable object producing bytes.
 |        Bytes and bytearray are examples of built-in objects that support the
 |        buffer protocol.
 |      byteorder
 |        The byte order used to represent the integer.  If byteorder is 'big',
 |        the most significant byte is at the beginning of the byte array.  If
 |        byteorder is 'little', the most significant byte is at the end of the
 |        byte array.  To request the native byte order of the host system, use
 |        `sys.byteorder' as the byte order value.
 |      signed
 |        Indicates whether two's complement is used to represent the integer.
 |  
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |  
 |  __new__(*args, **kwargs) from builtins.type
 |      Create and return a new object.  See help(type) for accurate signature.
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  denominator
 |      the denominator of a rational number in lowest terms
 |  
 |  imag
 |      the imaginary part of a complex number
 |  
 |  numerator
 |      the numerator of a rational number in lowest terms
 |  
 |  real
 |      the real part of a complex number

可以用以下代码,批量抓取帮助文档,部分文档的内容很有学习参考价值。

import sys
str=["int","float","complex","str","array","list","tuple","set","dict",
     "math","cmath","random","sys","os","json","pickle","shelve","xml",
     "re","logging","getpass","subprocess","hashlib","shutil","time",
     "datetime","configparser","traceback","itertools",
     "openpyxl","pyautogui","pymysql","numpy","pandas","scipy","six",
     "matplotlib","pybrain","ipython","seaborn","anaconda","yaml",
     "esptool","jupyter","sympy","markupsafe","pymsgbox","mouseifo",
     "win32api","win32con","win32gui","help"]
i = 0
out = sys.stdout #保存标准输出流
for s in str:
    i += 1
    fn = "help" + ("%03d" % i) + "_" + s + ".txt"
    f=open(fn, 'w')
    sys.stdout = f
    help(s)
    f.close()
sys.stdout = out #恢复标准输出流
print("end")


帮助文档清单:

   E:\Python>dir help*

    驱动器 E 中的卷没有标签。

    卷的序列号是 000D-8746

    E:\Python 的目录

   2021/03/24 周三  23:23              7,376 help001_int.txt

   2021/03/24 周三  23:23              5,393 help002_float.txt

   2021/03/24 周三  23:23              3,055 help003_complex.txt

   2021/03/24 周三  23:23            15,060 help004_str.txt

   2021/03/24 周三  23:23            18,132 help005_array.txt

   2021/03/24 周三  23:23              3,730 help006_list.txt

   2021/03/24 周三  23:23              2,026 help007_tuple.txt

   2021/03/24 周三  23:23              4,323 help008_set.txt

   2021/03/24 周三  23:23              3,891 help009_dict.txt

   2021/03/24 周三  23:23              8,109 help010_math.txt

   2021/03/24 周三  23:23              2,949 help011_cmath.txt

   2021/03/24 周三  23:23            25,506 help012_random.txt

   2021/03/24 周三  23:23            15,424 help013_sys.txt

   2021/03/24 周三  23:23            51,197 help014_os.txt

   2021/03/24 周三  23:23            24,838 help015_json.txt

   2021/03/24 周三  23:23            21,188 help016_pickle.txt

   2021/03/24 周三  23:23            18,570 help017_shelve.txt

   2021/03/24 周三  23:23              1,225 help018_xml.txt

   2021/03/24 周三  23:23            18,428 help019_re.txt

   2021/03/24 周三  23:23            51,018 help020_logging.txt

   2021/03/24 周三  23:23              3,728 help021_getpass.txt

   2021/03/24 周三  23:23            22,244 help022_subprocess.txt

   2021/03/24 周三  23:23            14,001 help023_hashlib.txt

   2021/03/24 周三  23:23            23,320 help024_shutil.txt

   2021/03/24 周三  23:23            11,092 help025_time.txt

   2021/03/24 周三  23:23            21,670 help026_datetime.txt

   2021/03/24 周三  23:23            79,356 help027_configparser.txt

   2021/03/24 周三  23:23            18,562 help028_traceback.txt

   2021/03/24 周三  23:23            20,645 help029_itertools.txt

   2021/03/24 周三  23:23                 942 help030_openpyxl.txt

   2021/03/24 周三  23:23            50,019 help031_pyautogui.txt

   2021/03/24 周三  23:23            83,204 help032_pymysql.txt

   2021/03/24 周三  23:23       2,573,280 help033_numpy.txt

   2021/03/24 周三  23:23              3,354 help034_pandas.txt

   2021/03/24 周三  23:23       1,866,667 help035_scipy.txt

   2021/03/24 周三  23:23            21,210 help036_six.txt

   2021/03/24 周三  23:23            24,818 help037_matplotlib.txt

   2021/03/24 周三  23:23                   73 help038_pybrain.txt

   2021/03/24 周三  23:23                 139 help039_ipython.txt

   2021/03/24 周三  23:23                 733 help040_seaborn.txt

   2021/03/24 周三  23:23                 140 help041_anaconda.txt

   2021/03/24 周三  23:23            13,057 help042_yaml.txt

   2021/03/24 周三  23:23          187,145 help043_esptool.txt

   2021/03/24 周三  23:23                 200 help044_jupyter.txt

   2021/03/24 周三  23:23     30,978,676 help045_sympy.txt

   2021/03/24 周三  23:23            20,481 help046_markupsafe.txt

   2021/03/24 周三  23:23              1,705 help047_pymsgbox.txt

   2021/03/24 周三  23:23                 140 help048_mouseifo.txt

   2021/03/24 周三  23:23            10,124 help049_win32api.txt

   2021/03/24 周三  23:23          129,227 help050_win32con.txt

   2021/03/24 周三  23:23            13,720 help051_win32gui.txt

   2021/03/24 周三  23:23          126,032 help052_help.txt

   2021/03/24 周三  23:24          833,031 help_Python.rar

                 53 个文件     37,454,173 字节

                  0 个目录 162,196,828,160 可用字节

   E:\Python>



目录
相关文章
|
2天前
|
开发者 Python
Python入门:8.Python中的函数
### 引言 在编写程序时,函数是一种强大的工具。它们可以将代码逻辑模块化,减少重复代码的编写,并提高程序的可读性和可维护性。无论是初学者还是资深开发者,深入理解函数的使用和设计都是编写高质量代码的基础。本文将从基础概念开始,逐步讲解 Python 中的函数及其高级特性。
Python入门:8.Python中的函数
|
1天前
|
数据采集 存储 前端开发
用Python抓取亚马逊动态加载数据,一文读懂
用Python抓取亚马逊动态加载数据,一文读懂
|
3月前
|
搜索推荐 Python
利用Python内置函数实现的冒泡排序算法
在上述代码中,`bubble_sort` 函数接受一个列表 `arr` 作为输入。通过两层循环,外层循环控制排序的轮数,内层循环用于比较相邻的元素并进行交换。如果前一个元素大于后一个元素,就将它们交换位置。
155 67
|
1月前
|
Python
[oeasy]python057_如何删除print函数_dunder_builtins_系统内建模块
本文介绍了如何删除Python中的`print`函数,并探讨了系统内建模块`__builtins__`的作用。主要内容包括: 1. **回忆上次内容**:上次提到使用下划线避免命名冲突。 2. **双下划线变量**:解释了双下划线(如`__name__`、`__doc__`、`__builtins__`)是系统定义的标识符,具有特殊含义。
32 3
|
1月前
|
JSON 监控 安全
深入理解 Python 的 eval() 函数与空全局字典 {}
`eval()` 函数在 Python 中能将字符串解析为代码并执行,但伴随安全风险,尤其在处理不受信任的输入时。传递空全局字典 {} 可限制其访问内置对象,但仍存隐患。建议通过限制函数和变量、使用沙箱环境、避免复杂表达式、验证输入等提高安全性。更推荐使用 `ast.literal_eval()`、自定义解析器或 JSON 解析等替代方案,以确保代码安全性和可靠性。
45 2
|
1月前
|
存储 人工智能 Python
[oeasy]python061_如何接收输入_input函数_字符串_str_容器_ 输入输出
本文介绍了Python中如何使用`input()`函数接收用户输入。`input()`函数可以从标准输入流获取字符串,并将其赋值给变量。通过键盘输入的值可以实时赋予变量,实现动态输入。为了更好地理解其用法,文中通过实例演示了如何接收用户输入并存储在变量中,还介绍了`input()`函数的参数`prompt`,用于提供输入提示信息。最后总结了`input()`函数的核心功能及其应用场景。更多内容可参考蓝桥、GitHub和Gitee上的相关教程。
16 0
|
2月前
|
Python
Python中的函数是**一种命名的代码块,用于执行特定任务或计算
Python中的函数是**一种命名的代码块,用于执行特定任务或计算
65 18
|
2月前
|
数据可视化 DataX Python
Seaborn 教程-绘图函数
Seaborn 教程-绘图函数
87 8
|
2月前
|
Python
Python中的函数
Python中的函数
63 8
|
3月前
|
监控 测试技术 数据库
Python中的装饰器:解锁函数增强的魔法####
本文深入探讨了Python语言中一个既强大又灵活的特性——装饰器(Decorator),它以一种优雅的方式实现了函数功能的扩展与增强。不同于传统的代码复用机制,装饰器通过高阶函数的形式,为开发者提供了在不修改原函数源代码的前提下,动态添加新功能的能力。我们将从装饰器的基本概念入手,逐步解析其工作原理,并通过一系列实例展示如何利用装饰器进行日志记录、性能测试、事务处理等常见任务,最终揭示装饰器在提升代码可读性、维护性和功能性方面的独特价值。 ####

热门文章

最新文章