Python Standard Library

The Python standard library includes a wide variety of modules and packages that can help you accomplish many common programming tasks—from file input/output (I/O), regular expressions, and mathematical operations to networking, data serialization, and working with dates and times. This wide range of functionality is why the Python community often says that Python is batteries-included.

The standard library is designed to be both broad and deep. It includes modules for low-level system interaction like os, sys, and subprocess, as well as high-level tools like csv for handling structured text, json for working with JSON data, http.server for creating simple web servers, and sqlite3 for embedded databases.

You’ll also find powerful utilities like itertools and functools for functional programming patterns, collections for specialized data structures, and more.

Because these modules are part of the Python distribution itself, you don’t need to install anything separately—making it easy to write portable, efficient programs that work out of the box across different environments and platforms.

In practice, the standard library covers a wide variety of use cases, including:

  • System scripting and automation
  • Web development
  • Text and data processing
  • Basic networking and client-server communication
  • Concurrency and multithreading
  • Data storage and serialization

In short, the standard library is one of Python’s greatest strengths. It helps you do more with less—reducing the need for external dependencies while encouraging idiomatic, readable code.

  • argparse Provides a framework for creating user-friendly command-line interfaces (CLI).
  • array Provides an efficient data structure for creating arrays of values, which are stored more compactly than in standard lists.
  • asyncio Provides a framework for writing asynchronous programs using coroutines, event loops, and tasks.
  • calendar Provides classes and functions for calendar operations.
  • collections Provides specialized container data types that extend the capabilities of Python’s built-in containers like lists, tuples, sets, and dictionaries.
  • configparser Provides tools for handling configuration files.
  • contextlib Provides utilities for working with context managers, allowing you to allocate and release resources precisely.
  • copy Provides functionality to create shallow and deep copies of objects in Python.
  • csv Provides functionality to read from and write to CSV (comma-separated values) files.
  • dataclasses Provides functionality for creating user-defined data classes.
  • datetime Contains classes and tools for manipulating dates and times.
  • decimal Provides support for correctly rounded decimal floating-point arithmetic.
  • doctest Provides tools for testing your code by running tests embedded in docstrings.
  • email Provides a library for managing email messages.
  • enum Provides support for enumerations of constant values known as members.
  • fractions Provides support for rational number arithmetic.
  • functools Provides higher-order functions and operations on callable objects.
  • gc Provides an interface to the garbage collection facility for Python.
  • gettext Provides internationalization (I18N) and localization (L10N) services for your Python applications.
  • glob Provides tools to find path names matching specified patterns that follow Unix shell rules.
  • hashlib Provides a common interface to many secure hash and message digest algorithms, such as SHA-256 and MD5.
  • heapq Provides an implementation of the heap queue algorithm, also known as the priority queue algorithm.
  • html Provides utilities for manipulating HTML data, including escaping and unescaping HTML entities and tags.
  • http Provides a set of modules for working with HTTP requests and responses.
  • imaplib Provides tools for interacting with mail servers using the Internet Message Access Protocol (IMAP).
  • importlib Provides a framework for the import statement, allowing for the importing of modules in Python.
  • inspect Provides several useful functions to help you get information about live objects, such as modules, classes, methods, functions, tracebacks, and the objects’ source code.
  • io Provides the main facilities for dealing with various types of I/O, including reading and writing files, handling binary data, and working with streams.
  • itertools Provides a collection of tools to perform fast and memory-efficient iteration.
  • json Provides tools to encode and decode data in JavaScript Object Notation (JSON).
  • keyword Provides functionality to work with Python’s reserved keywords.
  • locale Provides a way to handle operations related to the localization of programs, such as formatting numbers, dates, and currencies according to the conventions of different locales.
  • logging Provides a framework for generating log messages from Python programs.
  • math Provides a comprehensive collection of mathematical functions and constants.
  • mimetypes Provides tools to map filenames to MIME types and vice versa.
  • mmap Maps files or devices into memory.
  • multiprocessing Allows you to create parallel programs by leveraging multiple processors on your machine.
  • numbers Provides an abstract hierarchy of numeric types.
  • operator Provides functions that correspond to the Python operators.
  • os Provides tools for using operating system-dependent functionality.
  • pathlib Provides an object-oriented approach to handling file system paths.
  • pickle Provides tools to serialize and deserialize Python objects.
  • platform Provides access to underlying platform-specific data, such as the operating system, interpreter, and hardware architecture.
  • pprint Provides the capability to pretty-print data structures in a readable and easy-to-understand way.
  • queue Provides reliable thread-safe implementations of the queue data structure.
  • random Provides tools for generating random numbers and performing random operations.
  • re Provides support for working with regular expressions.
  • secrets Provides a straightforward and secure way to generate cryptographically strong random numbers.
  • shutil Provides a higher-level interface for file operations, including copying and removal.
  • socket Provides a low-level networking interface that allows you to create and use sockets for network communication.
  • sqlite3 Provides an interface for interacting with SQLite databases.
  • string Provides a collection of string constants and utility functions for common string operations.
  • subprocess Allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes.
  • sys Provides access to system-specific parameters and functions.
  • sysconfig Provides access to Python’s configuration information, which includes details about the installation paths, the build environment, and platform-specific settings.
  • tarfile Provides a powerful and flexible way to read and write tar archives.
  • tempfile Provides a simple way to create temporary files and directories.
  • threading Provides a higher-level interface for working with threads.
  • time Provides various time-related functions.
  • timeit Provides a simple way to measure the execution time of small code snippets.
  • tkinter Provides a powerful object-oriented interface to the Tk GUI toolkit.
  • tomllib Provides a simple way to parse TOML files.
  • traceback Provides utilities for working with error tracebacks.
  • turtle Provides tools to create pictures and shapes by controlling a turtle that draws on a canvas.
  • typing Provides support for type hints.