What are the Python standard libraries?

Overview
Usability notes
built-in functions
Built-in constants
Constants added by the site module

# @Author: Little Red Bull
# WeChat public account: wdPython

built-in types
Logical value detection
Boolean operations – and, or, not
comparison operation
Numeric types – int, float, complex
Boolean type – bool
iterator type
Sequence types – list, tuple, range
Text sequence type – str
Binary sequence types – bytes, bytearray, memoryview
Collection types – set, frozenset
Mapping type – dict
Context manager type
Types of type annotations – Generic Alias, Union
Other built-in types
Special properties
Integer string conversion length limit
Built-in exceptions
exception context
Inherited from built-in exceptions
base class
Specific exception
warn
abnormal group
exception hierarchy
text processing service
string – Common string operations
re – Regular expression manipulation
difflib – Helper for calculating differences
textwrap – automatic text wrapping and padding
unicodedata – Unicode database
stringprep – Internet string preparation
readline – GNU readline interface
rlcompleter – Completion function for GNU readline
binary data service
struct – Interpret byte strings as packed binary data
codecs – Codec registration and related base classes
type of data
datetime – basic date and time types
zoneinfo – IANA time zone support
calendar – Calendar related functions
collections – container data types
collections.abc – Abstract base class for containers
heapq – heap queue algorithm
bisect – Array binary search algorithm
array – Efficient array of numbers
weakref – weak reference
types – Dynamic type creation and built-in type names
copy – shallow and deep copy operations
pprint – data beautification output
reprlib – An alternative repr() implementation
enum – support for enumerations
graphlib – Functions for manipulating graph-like structures
Numbers and Mathematics Module
numbers – abstract base class for numbers
math – mathematical function
cmath – mathematical functions on complex numbers
decimal – Decimal fixed-point and floating-point arithmetic
fractions – fractions
random – generate pseudo-random numbers
statistics – mathematical statistical functions
Functional programming module
itertools – Functions for creating 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 paths
os.path – Common path operations
fileinput – iterate over lines from multiple input streams
stat – parse stat() results
filecmp – Compare files and directories
tempfile – generate temporary files and directories
glob – Unix-style pathname pattern expansion
fnmatch – Unix filename pattern matching
linecache – read and write random lines of text
shutil – high-level file operations
Data persistence
pickle – Python object serialization
copyreg – Register functions for use with the pickle module
shelve – Python object persistence
marshal – Internal Python object serialization
dbm – Unix “database” interface
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 the bzip2 compression algorithm
lzma – Compress using the LZMA algorithm
zipfile – archive using ZIP
tarfile – read and write tar archive files
file format
csv – CSV file reading and writing
configparser – Configuration file parser
tomllib – parse TOML files
netrc – netrc file handling
plistlib – Generate and parse Apple .plist files
Encryption service
hashlib – Secure hashes and message digests
hmac – Key-based message authentication
secrets – Generate secure random numbers for administrative passwords
Common operating system services
os – Multiple operating system interfaces
io – core tools for handling streams
time – time access and conversion
argparse – Command line option, argument, and subcommand parser
getopt – C-style command line option parser
logging – Logging tool for Python
logging.config – logging configuration
logging.handlers – logging handlers
getpass – portable password entry tool
curses – Handling of terminal character unit display
curses.textpad – Text input control for curses programs
curses.ascii – Tools for ASCII characters
curses.panel – Panel stack extension for curses
platform – Gets the identification data of the underlying platform
errno – Standard errno system symbol
ctypes – External function library for Python
Concurrent execution
threading – thread-based parallelism
multiprocessing – process-based parallelism
multiprocessing.shared_memory – shared memory directly accessible across processes
The concurrent package
concurrent.futures – start parallel tasks
subprocess – subprocess management
sched – event scheduler
queue – a synchronous queue class
contextvars – context variables
_thread – low-level multithreading API
Networking and inter-process communication
asyncio – Asynchronous I/O
socket – low-level network interface
ssl – TLS/SSL wrapper for socket objects
select – wait for I/O to complete
selectors – high-level I/O multiplexing library
signal – Set up an asynchronous event handler
mmap – Memory mapped file support
Internet data processing
email – Email and MIME handling package
json – JSON encoder and decoder
mailbox – Manipulate mailboxes in multiple formats
mimetypes – Map filenames to MIME types
base64 – Base16, Base32, Base64, Base85 data encoding
binascii – Convert binary to ASCII code and vice versa
quopri – Encode and decode MIME-transcoded printable data
Structured markup processing tools
html – Hypertext Markup Language support
html.parser – Simple HTML and XHTML parser
html.entities – Definition of general HTML entities
XML processing module
xml.etree.ElementTree – ElementTree XML API
xml.dom – Document Object Model API
xml.dom.minidom – Minimal DOM implementation
xml.dom.pulldom – Supports building partial DOM trees
xml.sax – supports SAX2 parser
xml.sax.handler – Base class for SAX handlers
xml.sax.saxutils – SAX toolset
xml.sax.xmlreader – interface for XML parsers
xml.parsers.expat – Fast XML parsing using Expat
Internet protocols and support
webbrowser – Convenient web browser control tool
wsgiref – WSGI tooling and reference implementation
urllib – URL processing module
urllib.request – Extensible library for opening URLs
urllib.response – Response class used by urllib
urllib.parse is used to parse URLs
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
smtplib – SMTP protocol client
uuid – UUID object defined by RFC 4122
socketserver – A framework for web servers
http.server – HTTP server
http.cookies – HTTP state management
http.cookiejar – Cookie handling for HTTP clients
xmlrpc – XMLRPC server and client modules
xmlrpc.client – XML-RPC client access
xmlrpc.server – Basic XML-RPC server
ipaddress – IPv4/IPv6 manipulation library
multimedia services
wave – read and write WAV format files
colorsys – Convert between color systems
globalization
gettext – multilingual internationalization service
locale – internationalization services
program framework
turtle – turtle drawing
cmd – Supports a line-oriented command interpreter
shlex – simple lexical analysis
Tk Graphical User Interface (GUI)
tkinter – Python interface to Tcl/Tk
tkinter.colorchooser – Color selection dialog
tkinter.font – Tkinter font package
Tkinter dialog box
tkinter.messagebox – Tkinter message box
tkinter.scrolledtext – scrolling text control
tkinter.dnd – drag-and-drop support
tkinter.ttk – Tk style controls
tkinter.tix – TK extension package
IDLE
development tools
typing – support for type hints
pydoc – documentation generator and online help system
Python development mode
doctest – Python example for testing interactivity
unittest – unit testing framework
unittest.mock – Mock object library
unittest.mock – Getting Started Guide
2to3 – Automated Python 2 to 3 code transpilation
test – Python regression testing package
test.support – Tools for Python test suites
test.support.socket_helper – Tool for socket testing
test.support.script_helper – A test tool for Python execution
test.support.bytecode_helper – Support tool for testing correct bytecode generation
test.support.threading_helper – Tool for thread testing
test.support.os_helper – Tool for operating system testing
test.support.import_helper – Tool for importing tests
test.support.warnings_helper – Tool for warning testing
Debugging and analysis
Audit event table
bdb – debugger framework
faulthandler – Dump Python trace information
pdb – Debugger for Python
Python performance analyzer
timeit – measure the execution time of small code snippets
trace – Trace the execution of Python statements
tracemalloc – Trace memory allocations
Software packaging and distribution
ensurepip – bootstrap the pip installer
venv – Create a virtual environment
zipapp – Manage executable Python zip files
Python runtime services
sys – system-related formal parameters and functions
sys.monitoring – Execution event monitoring
sysconfig – Provides access to Python configuration information
builtins – built-in objects
main – the highest level code environment
warnings – control of warning messages
dataclasses – data classes
contextlib – Tools for with statement context
abc – abstract base class
atexit – Exit a handler
traceback – print or read stack trace information
future – Future statement definition
gc – Garbage collector interface
inspect – inspect an object
site – Configuration hook for the specified domain
Custom Python interpreter
code – Interpreter base class
codeop – compile Python code
Import module
zipimport – Import modules from Zip archives
pkgutil – package extension tool
modulefinder – Find modules used by a script
runpy – Find and execute Python modules
importlib – implementation of import
importlib.resources – reading, opening and accessing package resources
importlib.resources.abc – abstract base class for resources
importlib.metadata – access package metadata
sys.path module search path initialization
Python language service
ast – abstract syntax tree
symtable – access the compiler’s symbol table
token – Constants for use with Python parse trees
keyword – Check for Python keywords
tokenize – A token parser for Python code
tabnanny – Fuzzy indentation detection
pyclbr – Python module browser support
py_compile – Compile Python source files
compileall – Byte-compiled Python library
dis – Python bytecode disassembler
pickletools – pickle developer toolset
Windows system related modules
msvcrt – Useful routines from the MS VC++ runtime
winreg – access the Windows registry
winsound – audio playback interface for Windows systems
Unix-specific services
posix – The most common POSIX system calls
pwd – User password database
grp – group database
termios – POSIX-style tty control
tty – terminal control function
pty – Pseudo terminal tool
fcntl – system calls fcntl and ioctl
resource – resource usage information
Unix syslog library routines
Modules command-line interface (CLI)
superseded module
aifc – read and write AIFF and AIFC files
audioop – Process raw audio data
cgi – Common Gateway Interface support
cgitb – Traceback manager for CGI scripts
chunk – Read IFF chunked data
crypt – Function to verify Unix passwords
imghdr – Infer image type
mailcap – Mailcap file handling
msilib – Read and write Microsoft Installer files
nis – Sun’s NIS (Yellow Pages) interface
nntplib – NNTP protocol client
optparse – Parser for command line options
ossaudiodev – Access OSS-compatible audio devices
pipes – terminal pipe interface
sndhdr – Infer the type of a sound file
spwd – shadow password library
sunau – read and write Sun AU files
telnetlib – Telnet client
uu – Encode and decode uuencode files
xdrlib – Encode and decode XDR data