The help function is a built-in function of python (python built-in functions can be called directly without the need for import). It is a built-in function of python and can be used at any time. What can the help function do, how to use the help function to view the usage of the function in the python module, and what issues need to be paid attention to when using the help function, which is briefly described below.
I. Functions of the help () function
When writing code using python, python built-in functions or modules are often used. The usage of some uncommonly used functions or modules is not very clear. At this time, you need to use the help function to view help.
Note that the help () function is a detailed description of the function or module usage, and the dir () function is used to view the operation methods in the function or module, the output is the method list.
Ii. How to use the help function to view the usage of functions in the python Module
Enter parameters in brackets for help (). The procedure is simple. For example:
Copy codeThe Code is as follows: >>> help ('dir ')
Help on built-in function dir in module builtins:
Dir (...)
Dir ([object])-> list of strings
If called without an argument, return the names in the current scope.
Else, return an alphabetized list of names comprising (some of) the attribut
Es
Of the given object, and of attributes reachable from it.
If the object supplies a method named _ dir __, it will be used; otherwise
The default dir () logic is used and returns:
For a module object: the module's attributes.
For a class object: its attributes, and recursively the attributes
Of its bases.
For any other object: its attributes, its class's attributes, and
Recursively the attributes of its class's base classes.
3. Use the help function to view help instances
When writing the help () function usage method, you should fill in parameters in brackets. Pay attention to the parameter format here:
1. view the help of a module
Copy codeThe Code is as follows: >>> help ('sys ')
Then it opens the help document for this module.
2. view the help of a data type
Copy codeThe Code is as follows: >>> help ('str ')
Returns the string method and detailed description.
Copy codeThe Code is as follows: >>> a = [1, 2, 3]
>>> Help ()
At this time, help (a) will open the list Operation Method
Copy codeThe Code is as follows: >>> help (a. append)
The list append method help is displayed.