python help Function Instance Usage

  • 2021-08-12 03:12:12
  • OfStack

Some people say that there are two functions in py that can realize the understanding and use of all functions, and one of them is the help function that we will explain today. Some small partners may be unfamiliar, but the other function is dir function, so you can understand it. Both 1 must be related to queries, yes, the help function is often said to be a universal query function for the following reasons.

help () syntax description

1. Syntax:


help([object])

2. Use with for:

If I forget what the for keyword means, how to use it? Easy to do, open your editor and enter the following command:


help('for')

help () use example

3. View help information for the package

View the help information for the tkinter package by executing help ('tkinter'):

4. View help information for a function under a class under a package/module

The code is as follows:


>>> help('tkinter.XView.xview')
Help on function xview in tkinter.XView:
tkinter.XView.xview = xview(self, *args)
Query and change the horizontal position of the view.

Extension of knowledge points:

help function is python a built-in function, in python basic knowledge introduced what is built-in function, it is python self-contained function, any time can be made. What can help function do, how to use help function to see the usage of python module learning function, and what problems should be paid attention to when using help function, let's simply say 1.

What can the help function do

When using python to write code, you often use python to call functions, bring your own functions or modules, and the purpose of some infrequent functions or modules is not very clear, so you need help functions to view help.

Note here that the help () function is to see a detailed description of the purpose of the function or module, while the dir () function is to see what the operation methods in the function or module are, and the output is a list of methods.

How to use help function to view the usage of functions in python module

help () parentheses fill in the parameters, the operation method is very simple.


Related articles: