Python Help () function usage detailed

Source: Internet
Author: User
The Help function is a built-in function of Python (Python's built-in function can be called directly without import), and it is a python-brought function that can be used at any time. What can I do with the help function, how to see the usage of functions in the Python module, and what to look for in the function with help, let's simply say.

role of the Help () function
When you use Python to write code, you often use Python's own functions or modules, and some of the less commonly used functions or modules are not very clear, so you need to use the Help function to see the aid.
Note here that the Help () function is a detailed description of the purpose of the function or module, and the Dir () function is to see what the action methods within a function or module are, and the output is a list of methods.
How to use the Help function to view the usage of functions in a Python module
Help () Fill in the parameters in parentheses, the operation method is very simple. For example:

The 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 of 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'll 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 the object:its attributes, its class ' s attributes, and
Recursively the attributes of its class ' s base classes.

Third, use the Help function to view the helper instance

When writing the Help () function using the method, the parentheses fill in the parameters, which should be noted here in the form of the parameter:

1. View Help for a module

The code is as follows:

>>>help (' sys ')


Then it opens the Help document for this module
2. View Help for a data type

The code is as follows:

>>>help (' str ')


Method and detailed description of the return string

The code is as follows:

>>>a = [A]
>>>help (a)


Then Help (a) will open the list operation method

The code is as follows:

>>>help (A.append)


Displays help for the list's Append method
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.