python内置函数-帮助(help)

help函数用户查看函数或者模块的详细说明。

语法

help(thing)

参数

  • thing: 对象。

返回值

  • 参数的详细使用说明。

注意

  • help()方法的内容不需要使用print输出。

示例

str = '我爱我的爸妈'
print('查看字符串方法find()的详细说明:')
help(str.find)
查看字符串方法find()的详细说明:
Help on built-in function find:

find(...) method of builtins.str instance
    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.

help(help)

Help on _Helper in module _sitebuiltins object:

class _Helper(builtins.object)
 |  Define the builtin 'help'.
 |  
 |  This is a wrapper around pydoc.help that provides a helpful message
 |  when 'help' is typed at the Python interactive prompt.
 |  
 |  Calling help() at the Python prompt starts an interactive help session.
 |  Calling help(thing) prints help for the python object 'thing'.
 |  
 |  Methods defined here:
 |  
 |  __call__(self, *args, **kwds)
 |      Call self as a function.
 |  
 |  __repr__(self)
 |      Return repr(self).
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
posted @ 2022-04-05 13:14  freepc  阅读(311)  评论(0)    收藏  举报