Comprehensive Overview of Python Standard Library Modules
This article provides a detailed, categorized reference of Python's standard library modules, covering text processing, data types, mathematics, functional programming, file handling, persistence, compression, encryption, OS utilities, concurrency, inter‑process communication, internet protocols, multimedia, internationalization, frameworks, GUI toolkits, development tools, debugging, runtime, interpreter internals, import mechanisms, language utilities, as well as Windows‑ and Unix‑specific modules.
Implementation of 200 similar standard library categories with differences distinguished.
Ctrl+F to search directly.
Text
string: General string operations
re: Regular expression operations
difflib: Difference calculation tools
textwrap: Text filling
unicodedata: Unicode character database
stringprep: Internet string preparation utilities
readline: GNU line‑reading interface
rlcompleter: GNU line‑reading implementation functions
struct: Convert bytes to packed binary data
codecs: Registry and base classes for codecs
Data Types
datetime: Date and time utilities
calendar: General month functions
collections: Container data types
collections.abc: Abstract base classes for containers
heapq: Heap queue algorithm
bisect: Array binary search algorithm
array: Efficient numeric arrays
weakref: Weak references
types: Dynamic creation and naming of built‑in types
copy: Shallow and deep copy
reprlib: Alternate implementation of repr()
Mathematics
numbers: Abstract base class for numbers
math: Mathematical functions
cmath: Mathematical functions for complex numbers
decimal: Fixed‑point and floating‑point arithmetic
fractions: Rational numbers
random: Pseudo‑random number generation
Functional Programming
itertools: Efficient iterator building blocks for loops
functools: Higher‑order functions and operations on callables
operator: Standard operators as functions
Files and Directories
os.path: Generic pathname manipulations
fileinput: Iterate over lines from multiple input streams
stat: Interpret results of stat()
filecmp: File and directory comparison functions
tempfile: Generate temporary files and directories
glob: Unix‑style pathname pattern expansion
fnmatch: Unix‑style filename matching
linecache: Random access to text lines
shutil: High‑level file operations
macpath: MacOS 9 pathname control functions
Persistence
pickle: Python object serialization
copyreg: Support functions for pickle
shelve: Persistent storage of Python objects
marshal: Internal Python object serialization
dbm: Unix “database” interface
sqlite3: API 2.0 for SQLite databases
Compression
zlib: gzip‑compatible compression
gzip: Support for gzip files
bz2: Support for bzip2 compression
lzma: Compression using the LZMA algorithm
zipfile: Working with ZIP archives
tarfile: Reading and writing tar archive files
Encryption
hashlib: Secure hashes and message digests
hmac: Keyed hashing for message authentication
Operating System Tools
os: Multi‑faceted operating system interface
io: Core tools for streams
time: Time queries and conversions
argparser: Command‑line option, argument, and sub‑command parser
optparser: Command‑line option parser
getopt: C‑style command‑line option parser
logging: Python logging utilities
logging.config: Logging configuration
logging.handlers: Logging handlers
getpass: Simple password input
curses: Terminal handling for character displays
curses.textpad: Text input widget for curses programs
curses.ascii: ASCII character utilities
curses.panel: Panel extensions for curses
platform: Access underlying platform identification data
errno: Standard error numbers
ctypes: Foreign function library for Python
Concurrency
threading: Thread‑based parallelism
multiprocessing: Process‑based parallelism
concurrent: Concurrency package
concurrent.futures: Launch parallel tasks
subprocess: Subprocess management
sched: Event scheduling
queue: Synchronous queues
select: Wait for I/O completion
dummy_threading: Threading module substitute when _thread is unavailable
_thread: Low‑level thread API (threading builds on it)
_dummy_thread: Substitute for _thread when unavailable
Inter‑Process Communication
socket: Low‑level network interface
ssl: TLS/SSL wrapper for socket objects
asyncore: Asynchronous socket handler
asynchat: Asynchronous socket command/response handler
signal: Asynchronous signal handling
mmap: Memory‑mapped file support
Internet
email: Email and MIME handling package
json: JSON encoding and decoding
mailcap: Mailcap file handling
mailbox: Multiple format mailbox control
mimetypes: Mapping filenames to MIME types
base64: RFC 3548 Base16, Base32, Base64 encoding
binhex: Binhex4 file encoding and decoding
binascii: Binary‑ASCII conversions
quopri: MIME‑quoted printable encoding/decoding
uu: UUEncode file encoding/decoding
Internet Protocols and Support
webbrowser: Simple web‑browser controller
cgi: CGI support
cgitb: CGI script traceback manager
wsgiref: WSGI utilities and reference implementation
urllib: URL handling modules
urllib.request: Extensions for opening URL connections
urllib.response: Response classes for urllib
urllib.parse: Parse URLs into components
urllib.error: Exception classes raised by urllib.request
urllib.robotparser: Robots.txt parser
http: HTTP module
http.client: HTTP protocol client
ftplib: FTP protocol client
poplib: POP protocol client
imaplib: IMAP4 protocol client
nntplib: NNTP protocol client
smtplib: SMTP protocol client
smtpd: SMTP server
telnetlib: Telnet client
uuid: UUID objects per RFC 4122
socketserver: Network server framework
http.server: HTTP server
http.cookies: HTTP cookie state manager
http.cookiejar: Cookie handling for HTTP clients
xmlrpc: XML‑RPC server and client modules
xmlrpc.client: XML‑RPC client access
xmlrpc.server: Basic XML‑RPC server
ipaddress: IPv4/IPv6 address manipulation library
Multimedia
audioop: Manipulate raw audio data
aifc: Read/write AIFF and AIFC files
sunau: Read/write Sun AU files
wave: Read/write WAV files
chunk: Read IFF chunked files
colorsys: Convert between color systems
imghdr: Determine image type
sndhdr: Determine sound file type
ossaudiodev: Access OSS‑compatible audio devices
Internationalization
gettext: Multilingual internationalization services
locale: Internationalization services
Programming Frameworks
turtle: Turtle graphics library
cmd: Line‑oriented command interpreter support
shlex: Simple lexical analysis
Tk GUI
tkinter: Tcl/Tk interface
tkinter.ttk: Tk themed widgets
tkinter.tix: Tk extended widgets
tkinter.scrolledtext: Scrolled‑text widget
Development Tools
pydoc: Documentation generator and online help system
doctest: Interactive Python examples
unittest: Unit testing framework
unittest.mock: Mock object library
test: Python regression test package
test.support: Python testing utilities
venv: Virtual environment creation
Debugging
bdb: Debugger framework
faulthandler: Python fault traceback
pdb: Python debugger
timeit: Measure execution time of small code snippets
trace: Trace Python execution
Runtime
sys: System‑specific parameters and functions
sysconfig: Access Python configuration information
builtins: Built‑in objects
main: Top‑level script environment
warnings: Warning control
contextlib: Context management utilities
abc: Abstract base classes
atexit: Exit handlers
traceback: Print or retrieve stack traces
future: Future statements
gc: Garbage collection interface
inspect: Inspect live objects
site: Site‑specific configuration hooks
fpectl: Floating‑point exception control
distutils: Build and install Python modules
Interpreter
code: Base class for interpreters
codeop: Compile Python code
Import Modules
imp: Access the internals of the import mechanism
zipimport: Import modules from ZIP archives
pkgutil: Package extension utilities
modulefinder: Find modules used by a script
runpy: Locate and run Python modules
importlib: Implementation of import
Python Language
parser: Access Python parse trees
ast: Abstract syntax trees
symtable: Access compiler symbol tables
symbol: Constants used by Python parse trees
token: Token constants used by Python parse trees
keyword: Keyword testing
tokenize: Tokenize Python source files
tabnanny: Indentation detection
pyclbr: Python class browsing support
py_compile: Compile Python source files
compileall: Byte‑compile Python libraries
dis: Disassembler for Python bytecode
pickletools: Tools for pickle development
Other
formatter: Generic output formatting
Windows‑related
msilib: Read/write Windows Installer files
msvcrt: Useful utilities from MS VC++ Runtime
winreg: Windows registry access
winsound: Windows sound playback interface
Unix‑related
posix: Common POSIX calls
pwd: Password database
spwd: Shadow password database
grp: Group database
crypt: Unix password verification
termios: POSIX‑style tty control
tty: Terminal control functions
pty: Pseudo‑terminal utilities
fcntl: System calls fcntl() and ioctl()
pipes: Shell pipe interface
resource: Resource usage information
nis: Sun NIS interface
syslog: Unix logging service
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.