current position:Home>The three main modules of Python that novice Xiaobai should know

The three main modules of Python that novice Xiaobai should know

2022-11-08 06:32:29q56731523

This article introduces the three main modules of Python in detail. Through the detailed introduction, they can all have certain reference value for everyone's study or work.

In python, a file (a file with the suffix ".py") is called a module, and each module is regarded as a separate file in python.

A module can be used by other modules in the project, some scripts or even interactive parsers. It can be referenced by other programs to use functions such as functions in the module. The standard library in Python also uses this method.a method.

Insert image description here
Let's talk about the main three types of Python modules:

1. System built-in modules

os module: The os module contains common operating system functions

sys module: provides a series of variables and functions related to the Python runtime environment

random module: the random module is used to generate random numbers

time module: mainly contains various classes and functions that provide date and time functions

datetime module: a high-level wrapper around the time module

shutil module: is a high-level file manipulation tool

logging module: prints logs to stdout

re module: can be called directly to achieve regular matching

pymysql module: connect to the database and implement simple addition, deletion, modification and query

threading module: provides a more powerful multi-thread management solution

queue module: implements a multi-producer, multi-consumer queue

json module: used to convert between strings and data types json

Of course there are other modules, you can continue to add in the comment area.Since each module has a lot of content, there is no example to introduce in detail, you can search for it on Google.

2. Open source (three-party) module

Requests: The most famous http library.Every Python programmer should have it.

Scrapy: This library is also essential for crawler-related work.

NumPy: Provides many advanced mathematical methods for Python.

matplotlib: A library for plotting data.Very useful for data analysts.

Pygame: It can be used when developing 2D games.

Scapy: A packet detection and analysis library written in Python.

Django: An open source web development framework that encourages rapid development and follows the MVC design with a short development cycle.

Py2exe: Convert python scripts into executable programs that can be run independently on windows.

BeautifulSoup: Python-based HTML/XML parser, easy to use.

PyGtk: Python-based GUI program development GTK+ library.

Of course, there are many common libraries in the three-party library. I hope you can continue to add them in the comment area.

3. Custom modules

A custom module is a module written by yourself, which encapsulates a certain piece of logic or certain functions for other functions to call.

Note: The name of the custom module must not be the same as the built-in module of the system, otherwise it will not be able to import the built-in module of the system.

For example: After customizing a sys.py module, you cannot use the system's sys module.

copyright notice
author[q56731523],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/312/202211080627232775.html

Random recommended