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>



目录
相关文章
|
14天前
|
存储 JavaScript Java
(Python基础)新时代语言!一起学习Python吧!(四):dict字典和set类型;切片类型、列表生成式;map和reduce迭代器;filter过滤函数、sorted排序函数;lambda函数
dict字典 Python内置了字典:dict的支持,dict全称dictionary,在其他语言中也称为map,使用键-值(key-value)存储,具有极快的查找速度。 我们可以通过声明JS对象一样的方式声明dict
69 1
|
14天前
|
算法 Java Docker
(Python基础)新时代语言!一起学习Python吧!(三):IF条件判断和match匹配;Python中的循环:for...in、while循环;循环操作关键字;Python函数使用方法
IF 条件判断 使用if语句,对条件进行判断 true则执行代码块缩进语句 false则不执行代码块缩进语句,如果有else 或 elif 则进入相应的规则中执行
103 1
|
14天前
|
Java 数据处理 索引
(numpy)Python做数据处理必备框架!(二):ndarray切片的使用与运算;常见的ndarray函数:平方根、正余弦、自然对数、指数、幂等运算;统计函数:方差、均值、极差;比较函数...
ndarray切片 索引从0开始 索引/切片类型 描述/用法 基本索引 通过整数索引直接访问元素。 行/列切片 使用冒号:切片语法选择行或列的子集 连续切片 从起始索引到结束索引按步长切片 使用slice函数 通过slice(start,stop,strp)定义切片规则 布尔索引 通过布尔条件筛选满足条件的元素。支持逻辑运算符 &、|。
76 0
|
25天前
|
设计模式 缓存 监控
Python装饰器:优雅增强函数功能
Python装饰器:优雅增强函数功能
233 101
|
1月前
|
缓存 测试技术 Python
Python装饰器:优雅地增强函数功能
Python装饰器:优雅地增强函数功能
170 99
|
1月前
|
存储 缓存 测试技术
Python装饰器:优雅地增强函数功能
Python装饰器:优雅地增强函数功能
150 98
|
1月前
|
缓存 Python
Python中的装饰器:优雅地增强函数功能
Python中的装饰器:优雅地增强函数功能
|
2月前
|
Python
Python 函数定义
Python 函数定义
146 1
|
1月前
|
算法 安全 数据安全/隐私保护
Python随机数函数全解析:5个核心工具的实战指南
Python的random模块不仅包含基础的随机数生成函数,还提供了如randint()、choice()、shuffle()和sample()等实用工具,适用于游戏开发、密码学、统计模拟等多个领域。本文深入解析这些函数的用法、底层原理及最佳实践,帮助开发者高效利用随机数,提升代码质量与安全性。
249 0
|
2月前
|
数据挖掘 数据处理 C++
Python Lambda:从入门到实战的轻量级函数指南
本文通过10个典型场景,详解Python中Lambda匿名函数的用法。Lambda适用于数据处理、排序、条件筛选、事件绑定等简洁逻辑,能提升代码简洁性和开发效率。同时提醒避免在复杂逻辑中过度使用。掌握Lambda,助你写出更高效的Python代码。
147 0

推荐镜像

更多