How to use python's help function

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

How to use python's help function
How to use Python's filter function
How to use the round function in python
How to use the zip function in Python
How to use the format function in python
How to use python tuples
How to use hanlp in ubuntu
How to use python thread pool
How to use SQLite in Python
How to use and and or in Python
How to use PYTHON to crawl news articles
How to run id function in python
How to use Samba server on Ubuntu 16.04
How to use Prometheus to monitor your Ubuntu 14.04 server
How to configure TensorFlow use environment in Ubuntu
How to install and use Docker on CentOS 7
How to use Nginx's map module on Ubuntu 16.04
How to install and use Docker on Ubuntu 20.04
How to use dpkg command in Ubuntu system
How to install and use Curl on Ubuntu 18.04
How to install and use Composer on Ubuntu 18.04
How to install and use Wine on Ubuntu 18.04
How to use Docker data volumes on Ubuntu 14.04
How to install and use Composer on CentOS 8
How to use code running assistant in python
How to install and use Composer on Ubuntu 20.04
How to install and use BaasBox on Ubuntu 14.04
How to use Jenkins to build automatically on Ubuntu
How to install and use PostgreSQL on Ubuntu 16.04
How to install and use Curl on CentOS 8
How to install and use Docker on Ubuntu 16.04
How to use LVM to manage storage devices on Ubuntu 18.04
How to create and use MongoDB backups on Ubuntu 14.04
How to upgrade to Ubuntu 20.04
How to install and use MySQL Workbench on Ubuntu 18.04
How to use Putty to log in to ubuntu installed in VirtualBox
How to install and use Cockpit on CentOS 8/RHEL 8
How to use Let's Encrypt to protect Nginx on CentOS 8
How to upgrade to Ubuntu 20.04
How to comment python code
How to write Pythonic code
How to learn python quickly
How to uninstall python plugin
How Python implements FTP function
How to understand python objects
Use virtualbox to deploy ubuntu
How to upgrade to Ubuntu 16.04 LTS
​Ubuntu Class|What is a key ring and how to use it?