In addition to providing __doc__ to query the document string, Python also provides another way to query the document string: Help
Here's a class we built ourselves, using Help to print, to form related report information
>>> class Test (): ' This is a test class ' Def HelloWorld (): ' Test method ' print (' Hello World ') >>> help (Test) to on class Test in Module __main__:class Test (builtins.object) | This is a Test class | | Methods defined here: | | HelloWorld () | Test Method | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | Dictionary for instance variables (if defined) | | __weakref__ |
Note: You must fill in the name when using Help, and you cannot use an empty object substitution, for example:
>>> Help (") >>> help (str) Help on Class str in module Builtins:class str (object) | STR (object= ")-str | STR (bytes_or_buffer[, encoding[, errors]), str |
However, if you call the method below the object, we can implement it by using an empty object
>>> help (". Upper) Help on built-in function upper:upper (...) method of Builtins.str instance S.upper ()-> ; STR Return a copy of S converted to uppercase.>>> help ([].append) Help on built-in function append:append (.. .) Method of Builtins.list Instance
It is also important to note that there is no parentheses behind the method, the parentheses will not be queried, even if the method must take parameters, and do not use parentheses
>>> help (". Replace)" On built-in function Replace:replace (...) method of Builtins.str instance S.replace (old, new[, Count])-STR Return a copy of S with all occurrences of the substring old replaced by new.
if The optional argument count is
In summary, this section provides a brief explanation of the use of Help
This chapter is here, thank you.
------------------------------------------------------------------
Click to jump 0 basic python-Catalogue
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
0 basic python-14.3 Python documentation resources: Help function