Consolidate the foundation of Python(7)

Consolidate the Python foundation

Seven, standard library

The Python standard library is another treasure house that Python programmers should be familiar with. The Python standard library is very large, and the components provided are very extensive. A brief description is as follows:

This library contains multiple built-in modules (written in C), and Python programmers must rely on them to implement system-level functions, such as file I/O.

In addition, there are a large number of modules written in Python that provide standard solutions to many problems in daily programming.

Among them, some modules are specially designed to encourage and strengthen the portability of Python programs by abstracting specific platform functions into platform-neutral APIs. It actually conveys a programming idea to Python programmers: through abstraction, coupling is reduced, and reusability is improved.

The Windows version of the Python installer usually contains the entire standard library and often many additional components.

For Unix-like operating systems, Python is usually divided into a series of software packages, so you may need to use the package management tools provided by the operating system to obtain some or all of the optional components.

In addition to this standard library, there are thousands and increasing other components (from individual programs, modules, software packages to complete application development frameworks). These third-party packages can be obtained by visiting the Python package index on the official website.

If we talked about the last issue of the module, we provided you with the first treasure map, then today is to provide you with the second treasure map you should collect.

The following is a detailed catalog of the Python 3.7 standard, with a detailed access address at the end of the article.

Overview

Usability note

Built-in functions

Built-in constant

Constants added by the site module

Built-in type

Logical value detection

Boolean operations--- and, or, not

Compare

Number type --- int, float, complex

Iterator type

Sequence type --- list, tuple, range

Text sequence type --- str

Binary sequence type --- bytes, bytearray, memoryview

Set type --- set, frozenset

Mapping type --- dict

Context manager type

Other built-in types

Special attributes

Built-in exception

Base class

Specific exception

caveat

Exception hierarchy

Text processing service

string --- common string operations

re --- regular expression operation

difflib --- An auxiliary tool for calculating differences

textwrap --- text wrap and fill

unicodedata --- Unicode database

stringprep --- Internet string preparation

readline --- GNU readline interface

rlcompleter --- The completion function of GNU readline

Binary Data Service

struct --- Interpret bytes as packed binary data

codecs --- Codec registry and base classes

type of data

datetime --- basic date and time data type

calendar --- calendar related functions

collections --- container data types

collections.abc --- abstract base class for containers

heapq --- Heap queue algorithm

bisect --- Array bisection algorithm

array --- Efficient arrays of numeric values

weakref --- weak reference

types --- Dynamic type creation and names for built-in types

copy --- Shallow (shallow) and deep (deep) copy operations

pprint --- Data beautification output

reprlib --- Alternate repr() implementation

enum --- Support for enumerations

Numbers and math module

numbers --- abstract base class for numbers

math --- mathematical functions

cmath-Mathematical functions on complex numbers

decimal --- Decimal fixed point and floating point arithmetic

fractions --- fractions

random --- Generate pseudo-random numbers

statistics --- Mathematical statistics functions

Functional programming module

itertools --- functions to create iterators for efficient looping

functools --- higher-order functions and operations on callable objects

operator --- Standard operator replacement function

File and directory access

pathlib --- object-oriented file system path

os.path --- common path operations

fileinput --- Iterate over lines from multiple input streams

stat --- Interpreting stat() results

filecmp --- Comparison of files and directories

tempfile --- Generate temporary files and directories

glob --- Unix style pathname pattern expansion

fnmatch --- Unix filename pattern matching

linecache --- Random access to text lines

shutil --- High-level file operations

macpath --- Mac OS 9 path manipulation functions

Data persistence

pickle-Python object serialization

copyreg --- Register pickle support functions

shelve --- Python object persistence

marshal --- Internal Python object serialization

dbm --- Interfaces to Unix "databases"

sqlite3 --- SQLite database DB-API 2.0 interface module

Data compression and archiving

zlib --- gzip compatible compression

gzip --- Support for gzip format

bz2 --- support for bzip2 compression algorithm

lzma --- Compress with LZMA algorithm

zipfile --- Use ZIP archive

tarfile --- read and write tar archive files

file format

csv --- CSV file read and write

configparser --- Configuration file parser

netrc --- netrc file processing

xdrlib --- Encode and decode XDR data

plistlib --- Generate and parse Mac OS X .plist files

Encryption Service

hashlib --- secure hash and message digest

hmac --- Key-based message authentication

secrets --- Generate secure random numbers for managing secrets

General operating system services

os --- Operating system interface module

io --- The core tool for processing streams

time --- Time access and conversion

argparse --- command line options, parameters and subcommand parser

getopt --- C-style parser for command line options

Module

logging --- Python logging tool

logging.config --- logging configuration

logging.handlers --- Logging handlers

getpass --- portable password input tool

curses --- terminal character unit display processing

curses.textpad --- Text input widget for curses programs

curses.ascii --- Utilities for ASCII characters

curses.panel --- A panel stack extension for curses

platform --- Get the identification data of the underlying platform

errno --- Standard errno system symbols

ctypes --- Python external function library

Concurrent execution

threading --- thread-based parallelism

multiprocessing --- process-based parallelism

concurrent package

concurrent.futures --- start parallel tasks

subprocess --- subprocess management

sched --- event scheduler

queue --- a synchronized queue class

_ thread --- Low-level multithreading API

_ dummy_thread --- Alternative module for _thread

dummy_threading --- can directly replace the threading module.

contextvars --- Context Variables

Context Variables

Manual Context Management

asyncio support

Network and inter-process communication

asyncio --- Asynchronous I/O

socket --- low-level network interface

ssl --- TLS/SSL wrapper for socket objects

select --- Waiting for I/O completion

selectors --- Advanced I/O reuse library

asyncore --- Asynchronous socket processor

asynchat --- Asynchronous socket command/response processor

signal --- Set asynchronous event handler

mmap --- memory mapped file support

Internet data processing

email --- Email and MIME handling package

json --- JSON encoder and decoder

mailcap --- Mailcap file handling

mailbox --- Manipulate mailboxes in various formats

mimetypes --- Map filenames to MIME types

base64 --- Base16, Base32, Base64, Base85 data encoding

binhex --- encode and decode binhex4 files

binascii --- Conversion between binary and ASCII codes

quopri --- Encode and decode MIME quoted-printable data

uu --- Encode and decode uuencode files

Structured markup processing tools

html --- Hypertext Markup Language Support

html.parser --- Simple HTML and XHTML parser

html.entities --- HTML general entity definition

XML processing module

xml.etree.ElementTree --- The ElementTree XML API

xml.dom --- The Document Object Model API

xml.dom.minidom --- Minimal DOM implementation

xml.dom.pulldom --- Support for building partial DOM trees

xml.sax --- Support for SAX2 parsers

xml.sax.handler --- Base classes for SAX handlers

xml.sax.saxutils --- SAX Utilities

xml.sax.xmlreader --- Interface for XML parsers

xml.parsers.expat --- Fast XML parsing using Expat

Internet protocol and support

webbrowser --- Convenient web browser controller

cgi --- Common Gateway Interface support

cgitb --- Traceback manager for CGI scripts

wsgiref --- WSGI Utilities and Reference Implementation

urllib --- URL processing module

urllib.request --- Extensible library for opening URL

urllib.response --- Response classes used by urllib

urllib.parse --- Parse URLs into components

urllib.error --- Exception class raised by urllib.request

urllib.robotparser --- robots.txt parser

http --- HTTP module

http.client --- HTTP protocol client

ftplib --- FTP protocol client

poplib --- POP3 protocol client

imaplib --- IMAP4 protocol client

nntplib --- NNTP protocol client

smtplib ---SMTP protocol client

smtpd --- SMTP Server

telnetlib --- Telnet client

uuid --- UUID objects according to RFC 4122

socketserver --- A framework for network servers

http.server --- HTTP server

http.cookies --- HTTP state management

http.cookiejar --- Cookie handling for HTTP clients

xmlrpc --- XMLRPC server and client module

xmlrpc.client --- XML-RPC client access

xmlrpc.server --- Basic XML-RPC servers

ipaddress --- IPv4/IPv6 manipulation library

Multimedia Service

audioop --- Manipulate raw audio data

aifc --- Read and write AIFF and AIFC files

sunau --- Read and write Sun AU files

wave --- Read and write WAV format files

chunk --- Read IFF chunked data

colorsys --- Conversion between color systems

imghdr --- guess the image type

sndhdr --- guess the type of sound file

ossaudiodev --- Access to OSS-compatible audio devices

globalization

gettext --- multilingual international service

locale --- Internationalization service

Program framework

turtle --- turtle drawing

cmd --- Support line-oriented command interpreter

shlex --- Simple lexical analysis

Tk Graphical User Interface (GUI)

tkinter --- Python interface for Tcl/Tk

tkinter.ttk --- Tk themed widgets

tkinter.tix --- Extension widgets for Tk

tkinter.scrolledtext --- scroll text control

IDLE

Other graphical user interface (GUI) packages

development tools

typing --- Type annotation support

pydoc --- Documentation generator and online help system

doctest --- Python example for testing interactivity

unittest --- unit testing framework

unittest.mock --- mock object library

Getting started with unittest.mock

2 to3-Automatically convert Python 2 code to Python 3 code

test --- Regression tests package for Python

test.support --- Utilities for the Python test suite

test.support.script_helper --- Utilities for the Python execution tests

Debug and analysis

bdb --- Debugger framework

faulthandler --- Dump the Python traceback

pdb --- Python debugger

The Python Profilers

timeit --- measure the execution time of small code snippets

trace --- Trace or track Python statement execution

tracemalloc --- Trace memory allocations

Software packaging and distribution

distutils --- Build and install Python modules

ensurepip --- Bootstrapping the pip installer

venv --- Create a virtual environment

zipapp --- Manage executable Python zip archives

Python runtime service

sys --- system-related parameters and functions

sysconfig --- Provide access to Python's configuration information

builtins --- built-in objects

__ main__ --- top-level script environment

warnings --- Warning control

dataclasses --- data classes

contextlib --- Utilities for with-statement contexts

abc --- abstract base class

atexit --- exit the processor

traceback --- print or retrieve stack traceback

__ future__ --- Future statement definition

gc --- Garbage collector interface

inspect --- inspect the object

site --- Site-specific configuration hook

Custom Python interpreter

code --- Interpreter base classes

codeop --- Compile Python code

Import module

zipimport --- Import modules from Zip archives

pkgutil --- Package extension utility

modulefinder --- Find the module used by the script

runpy --- Locating and executing Python modules

importlib --- implementation of import

Python Language Service

parser --- Access Python parse trees

ast --- abstract syntax tree

symtable --- Access to the compiler's symbol tables

symbol --- constant used with Python parse tree

token --- Constant used with Python parse tree

keyword --- Test Python keywords

tokenize --- Tokenizer for Python source

tabnanny --- fuzzy indentation detection

pyclbr --- Python class browser support

py_compile --- Compile Python source files

compileall --- Byte-compile Python libraries

dis --- Python bytecode disassembler

pickletools --- Tools for pickle developers

Miscellaneous Services

formatter --- Generic output formatting

Windows system related modules

msilib --- Read and write Microsoft Installer files

msvcrt --- Useful routines from the MS VC++ runtime

winreg --- Windows registry access

winsound --- Sound-playing interface for Windows

Unix proprietary services

posix --- The most common POSIX system calls

pwd --- user password database

spwd --- The shadow password database

grp --- The group database

crypt --- Function to check Unix passwords

termios --- POSIX style tty control

tty --- terminal control function

pty --- Pseudo-terminal utilities

fcntl --- The fcntl and ioctl system calls

pipes --- Interface to shell pipelines

resource --- Resource usage information

nis --- Interface to Sun's NIS (Yellow Pages)

Unix syslog library routines

Module superseded

optparse --- Parser for command line options

imp --- Access the import internals

Module with no document created

Platform specific modules

**Disclaimer: **This article is excerpted from official Python documentation

https://docs.python.org/zh-cn/3.7/library/index.html

Recommended Posts

Consolidate the foundation of Python (4)
Consolidate the foundation of Python(7)
Consolidate the foundation of Python(6)
Consolidate the foundation of Python(5)
Consolidate the foundation of Python (3)
Consolidate the Python foundation (2)
"Consolidating the Foundation of Python" (1)
The usage of wheel in python
Python handles the 4 wheels of Chinese
Python simulation of the landlord deal
What is the use of Python
The premise of Python string pooling
Secrets of the new features of Python 3.8
The father of Python joins Microsoft
The operation of python access hdfs
The usage of tuples in python
End the method of running python
Understanding the meaning of rb in python
Can Python implement the structure of the stack?
Learn the basics of python interactive mode
What are the required parameters of python
Logistic regression at the bottom of python
The usage of Ajax in Python3 crawler
Python solves the Tower of Hanoi game
Solve the conflict of multiple versions of python
7 features of Python3.9
What is the scope of python variables
Python implements the sum of fractional sequences
Two days of learning the basics of Python
What is the id function of python
Where is the pip path of python3
The essence of Python language: Itertools library
2.3 Python language foundation
What are the advantages of python language
The specific method of python instantiation object
2.1 The Python Interpreter (python interpreter)
python3 realizes the function of mask drawing
What is the prospect of python development
What is the function body of python
The specific method of python import library
Solve the conflict of multiple versions of python
What is the function of adb in python
Detailed explanation of the principle of Python super() method
The difference between the syntax of java and python
Python realizes the development of student management system
Python implements the shuffling of the cards in Doudizhu
The meaning and usage of lists in python
Solve the problem of python running startup error
Can the value of the python dictionary be modified?
Python implements the source code of the snake game
Detailed explanation of the usage of Python decimal module
How about learning python at the age of 27?
The consequences of uninstalling python in ubuntu, very
Python writes the game implementation of fishing master
Basics of Python syntax
Basic syntax of Python
Basic knowledge of Python (1)
Prettytable module of python
09. Common modules of Python3
Detailed explanation of the principle of Python function parameter classification
What is the advantage of python over corporate language