The Python standard library¶
This library reference manual describes the standard library distributed with Python. It also describes some of the optional components that are commonly included in Python distributions.
Elsewhere, Python 言語リファレンス describes the exact syntax and semantics of the Python language, and Python built-ins reference describes the built-in functions.
Python's standard library is extensive, offering a wide range of facilities as indicated by the long table of contents listed below. The library contains built-in modules (written in C) that provide access to system functionality such as file I/O that would otherwise be inaccessible to Python programmers, as well as modules written in Python that provide standardized solutions for many problems that occur in everyday programming. Some of these modules are explicitly designed to encourage and enhance the portability of Python programs by abstracting away platform-specifics into platform-neutral APIs.
Windows 向けの Python インストーラはたいてい標準ライブラリのすべてを含み、しばしばそれ以外の追加のコンポーネントも含んでいます。Unix 系のオペレーティングシステムの場合は Python は一揃いのパッケージとして提供されるのが普通で、オプションのコンポーネントを手に入れるにはオペレーティングシステムのパッケージツールを使うことになるでしょう。
標準ライブラリに加えて、数10万のコンポーネントが (独立したプログラムやモジュールからパッケージ、アプリケーション開発フレームワークまで) 活動しているコレクションとしてPython Package Index から入手可能です。
- はじめに
- テキスト処理サービス
- バイナリデータ処理
- データ型
datetime--- 基本的な日付と時間の型zoneinfo--- IANA タイムゾーンのサポートcalendar--- 一般的なカレンダーに関係する機能群collections--- コンテナデータ型collections.abc--- コンテナの抽象基底クラスheapq--- ヒープキューアルゴリズムbisect--- 配列二分法アルゴリズムarray--- 効率的な数値配列weakref--- Weak referencestypes--- 動的な型生成と組み込み型の名前copy--- 浅いコピーおよび深いコピー操作pprint--- データの整形表示reprlib--- もう一つのrepr()の実装enum--- 列挙型のサポートgraphlib--- グラフ構造を操作する機能
- 数値と数学モジュール
- 関数型プログラミング用モジュール
- ファイルとディレクトリへのアクセス
- データの永続化
- データ圧縮とアーカイブ
- ファイルフォーマット
- 暗号関連のサービス
- 汎用オペレーティングシステムサービス
- コマンドラインインターフェースライブラリ
argparse--- コマンドラインオプションや引数、サブコマンド向けのパーサーoptparse--- Parser for command line optionsgetpass--- 可搬性のあるパスワード入力機構fileinput--- 複数の入力ストリームをまたいだ行を反復するcurses--- 文字セル表示のターミナル処理curses.textpad--- Text input widget for curses programscurses.ascii--- ASCII 文字のユーティリティーcurses.panel--- curses のためのパネルスタック拡張cmd--- 行指向のコマンドインタープリターのサポート
- 並行実行
threading--- スレッドベースの並列処理multiprocessing--- プロセスベースの並列処理multiprocessing.shared_memory--- プロセス間で直接アクセス可能な共有メモリconcurrentパッケージconcurrent.futures--- 並列タスク実行concurrent.interpreters--- Multiple interpreters in the same processsubprocess--- サブプロセス管理sched--- イベントスケジューラーqueue--- 同期キュークラスcontextvars--- コンテキスト変数_thread--- 低水準なスレッド API
- ネットワーク通信とプロセス間通信
- インターネット上のデータの操作
- 構造化マークアップツール
html--- HyperText Markup Language のサポートhtml.parser--- HTML と XHTML のシンプルなパーサーhtml.entities--- HTML 一般実体の定義- XMLを扱うモジュール群
xml.etree.ElementTree--- ElementTree XML APIxml.dom--- ドキュメントオブジェクトモデル APIxml.dom.minidom--- 最小限の DOM の実装xml.dom.pulldom--- 部分的な DOM ツリー構築のサポートxml.sax--- SAX2 バーサーのサポートxml.sax.handler--- SAX ハンドラーの基底クラスxml.sax.saxutils--- SAX ユーティリティーxml.sax.xmlreader--- XML パーサーのインターフェースxml.parsers.expat--- Expat を使用した高速な XML 解析
- インターネットプロトコルとサポート
webbrowser--- 便利なウェブブラウザコントローラーwsgiref--- WSGI ユーティリティとリファレンス実装urllib--- URL を扱うモジュール群urllib.request--- URL を開くための大規模なライブラリurllib.response--- Response classes used by urlliburllib.parse--- URL を構成要素に解析するurllib.error--- urllib.request によって送出される例外クラスurllib.robotparser--- robots.txt 用のパーサーhttp--- HTTP モジュール群http.client--- HTTP プロトコルクライアントftplib--- FTP プロトコルクライアントpoplib--- POP3 プロトコルクライアントimaplib--- IMAP4 プロトコルクライアントsmtplib--- SMTP プロトコルクライアントuuid--- RFC 9562 に基づく UUID オブジェクトsocketserver--- ネットワークサーバーのフレームワークhttp.server--- HTTP サーバーhttp.cookies--- HTTP の状態管理http.cookiejar--- HTTP クライアント用の Cookie 処理xmlrpc--- XMLRPC サーバーとクライアントモジュール群xmlrpc.client--- XML-RPC クライアントアクセスxmlrpc.server--- 基本的な XML-RPC サーバーipaddress--- IPv4/IPv6 操作ライブラリ
- マルチメディアサービス
- 国際化
- Graphical user interfaces with Tk
tkinter--- Tcl/Tk の Python インターフェースtkinter.colorchooser--- カラー選択ダイアログtkinter.font--- Tkinter フォントラッパー- Tkinter dialogs
tkinter.messagebox--- Tkinter メッセージプロンプトtkinter.scrolledtext--- Scrolled text widgettkinter.dnd--- ドラッグアンドドロップのサポートtkinter.ttk--- Tk のテーマ付きウィジェット- IDLE --- Python のエディタとシェル
turtle--- Turtle graphics
- 開発ツール
typing--- 型ヒントのサポートpydoc--- ドキュメント生成とオンラインヘルプシステム- Python 開発モード
doctest--- 対話型の Python の例をテストするunittest--- ユニットテストフレームワークunittest.mock--- モックオブジェクトライブラリunittest.mock--- 入門test--- Regression tests package for Pythontest.support--- Utilities for the Python test suitetest.support.socket_helper--- Utilities for socket teststest.support.script_helper--- Utilities for the Python execution teststest.support.bytecode_helper--- Support tools for testing correct bytecode generationtest.support.threading_helper--- Utilities for threading teststest.support.os_helper--- Utilities for os teststest.support.import_helper--- Utilities for import teststest.support.warnings_helper--- Utilities for warnings tests
- Debugging and Profiling
- ソフトウェア・パッケージと配布
- Python ランタイムサービス
sys--- システム固有のパラメーターと関数sys.monitoring--- 実行イベントモニタリングsysconfig--- Python の構成情報へのアクセスを提供するbuiltins--- 組み込みオブジェクト__main__--- トップレベルのコード環境warnings--- 警告の制御dataclasses--- データクラスcontextlib---with文コンテキスト用ユーティリティabc--- 抽象基底クラスatexit--- 終了ハンドラーtraceback--- スタックトレースの表示または取得__future__--- future 文の定義gc--- ガベージコレクターインターフェースinspect--- 活動中のオブジェクトを調査するannotationlib--- Functionality for introspecting annotationssite--- サイト固有の設定フック
- カスタム Python インタプリタ
- モジュールのインポート
zipimport--- Zip アーカイブからモジュールをインポートするpkgutil--- パッケージ拡張ユーティリティmodulefinder--- スクリプト中で使用されているモジュールの検索runpy--- Python モジュールの位置特定と実行importlib---importの実装importlib.resources-- パッケージリソースの読み取り、オープン、アクセスimportlib.resources.abc-- リソースの抽象基底クラスimportlib.metadata-- パッケージメタデータへのアクセスsys.pathモジュール検索パスの初期化
- Python言語サービス
ast--- Abstract syntax treessymtable--- コンパイラーの記号表へのアクセスtoken--- Python 解析木で使われる定数keyword--- Python キーワードのテストtokenize--- Python ソース用のトークナイザーtabnanny--- あいまいなインデントの検出pyclbr--- Python モジュールブラウザーサポートpy_compile--- Python ソースファイルをコンパイルするcompileall--- Python ライブラリをバイトコンパイルするdis--- Python バイトコードの逆アセンブラーpickletools--- pickle 開発者用のツール群
- MS Windows 固有のサービス
- Unix-specific services
- モジュールのコマンドラインインターフェース (CLI)
- Superseded Modules
- 削除されたモジュール
- セキュリティで考慮すべき点