The help function is a built-in function of python. What is a built-in function is introduced in the basic knowledge of python. It is a function that comes with python and can be used at any time. What can the help function do, how to use the help function to check the usage of the function in the python module learning, and what issues need to be paid attention to when using the help function, let's briefly talk about it below.
What can the help function do
When using python to write code, you will often use python to call functions, built-in functions or modules. The purpose of some uncommon functions or modules is not very clear. At this time, you need to use the help function to view the help.
It should be noted here that the help() function is to view the detailed description of the purpose of the function or module, and the dir() function is to view the operation methods in the function or module, and the output is a list of methods.
How to use the help function to view the usage of functions in the python module
Help() fill in the parameters in parentheses, the operation method is very simple.
What issues should be paid attention to when using the help function to view help
When writing how to use the help() function, I said that the parameters should be filled in parentheses, so please pay attention to the form of the parameters here:
1、 View the help of a module
help('sys')
Then it will open the help file of this module
2、 View help for a data type
help('str')
Method and detailed description of returning string
a =[1,2,3]help(a)
At this time, help(a) will open the operation method of list
help(a.append)
The help of the append method of the list will be displayed.
Example extension:
How to use the help function to view the usage of functions in the python module
Help() fill in the parameters in parentheses, the operation method is very simple. E.g:
help('dir')
Help on built-infunction 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 defaultdir() logic is used and returns:for a module object: the module's attributes.for a classobject: 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.
So far, this article on how to use python's help function is introduced. For more information about how to use python's help function, please search for ZaLou.Cn's previous articles or continue to browse related articles below. Hope you will support ZaLou more in the future. .Cn!
Recommended Posts