The built-in modules in Python can be used directly, such as os module and sys module.
Before using a third-party module, you need to download and install the module, and then you can import and use it like standard modules and custom modules. Therefore, this section mainly explains how to download and install third-party modules.
To download and install third-party modules, you can use the pip command provided by Python. The syntax format of the pip command is as follows:
pip install module name
Among them, install, uninstall, and list are commonly used command parameters, and their meanings are:
Content expansion:
A Python module is simply a .py file, which can contain any Python code we need. All the programs we have written so far are contained in separate .py files, so they are both programs and modules. The key difference is that the design goal of the program is to run, while the design goal of the module is to be imported and used by other programs.
Not all programs have associated .py files-for example, the sys module is built into Python, and some modules are implemented in other languages (the most common is the C language). However, most of Python library files are implemented in Python. Therefore, for example, we use the statement import collections, and then we can create named tuples by calling collections.namedtuple(), and the functions we access are Implemented in the collections.py module file. For the program, it does not matter which language the module uses, because all modules are imported and used in the same way.
So far, this article on how to install the downloaded module in python is introduced here. For more related python module installation content, please search for the previous articles of ZaLou.Cn or continue to browse the related articles below. Hope you will support ZaLou.Cn more in the future. !
Recommended Posts