Python 標準庫非常龐大,所提供的組件涉及範圍十分廣泛,正如以下內容目錄所顯示的。這個庫包含了多個內置模塊 (以 C 編寫),Python 程序員必須依靠它們來實現系統級功能,例如文件 I/O,此外還有大量以 Python 編寫的模塊,提供了日常編程中許多問題的標準解決方案。其中有些模塊經過專門設計,通過將特定平臺功能抽象化爲平臺中立的 API 來鼓勵和加強 Python 程序的可移植性。
- 概述
- 內置函數
- 內置常量
- 內置類型
- 內置異常
- 文本處理服務
- 二進制數據服務
- 數據類型
- 數字和數學模塊
- 函數式編程模塊
- 文件和目錄訪問
- 數據持久化
- 數據壓縮和存檔
- 文件格式
- 加密服務
- 通用操作系統服務
os
--- 各種各樣的操作系統接口io
--- 處理流的核心工具time
--- 時間的訪問和轉換argparse
--- 命令行選項、參數和子命令解析器getopt
--- C-style parser for command line optionslogging
--- Python 的日誌記錄工具logging.config
--- 日誌記錄配置logging.handlers
--- 日誌處理getpass
--- 便攜式密碼輸入工具curses
--- 終端字符單元顯示的處理curses.textpad
--- Text input widget for curses programscurses.ascii
--- Utilities for ASCII characterscurses.panel
--- A panel stack extension for cursesplatform
--- 獲取底層平臺的標識數據errno
--- Standard errno system symbolsctypes
--- Python 的外部函數庫
- 併發執行
contextvars
--- Context Variables- 網絡和進程間通信
- 互聯網數據處理
email
--- 電子郵件與 MIME 處理包json
--- JSON 編碼和解碼器mailcap
--- Mailcap file handlingmailbox
--- Manipulate mailboxes in various formatsmimetypes
--- Map filenames to MIME typesbase64
--- Base16, Base32, Base64, Base85 數據編碼binhex
--- 對binhex4文件進行編碼和解碼binascii
--- 二進制和 ASCII 碼互轉quopri
--- 編碼與解碼經過 MIME 轉碼的可打印數據uu
--- 對 uuencode 文件進行編碼與解碼
- 結構化標記處理工具
html
--- 超文本標記語言支持html.parser
--- 簡單的 HTML 和 XHTML 解析器html.entities
--- HTML 一般實體的定義- XML處理模塊
xml.etree.ElementTree
--- ElementTree XML APIxml.dom
--- The Document Object Model APIxml.dom.minidom
--- Minimal DOM implementationxml.dom.pulldom
--- Support for building partial DOM treesxml.sax
--- Support for SAX2 parsersxml.sax.handler
--- Base classes for SAX handlersxml.sax.saxutils
--- SAX Utilitiesxml.sax.xmlreader
--- Interface for XML parsersxml.parsers.expat
--- Fast XML parsing using Expat
- 互聯網協議和支持
webbrowser
--- 方便的Web瀏覽器控制器cgi
--- Common Gateway Interface supportcgitb
--- 用於 CGI 腳本的回溯管理器wsgiref
--- WSGI Utilities and Reference Implementationurllib
--- URL 處理模塊urllib.request
--- 用於打開 URL 的可擴展庫urllib.response
--- urllib 使用的 Response 類urllib.parse
--- Parse URLs into componentsurllib.error
--- urllib.request 引發的異常類urllib.robotparser
--- robots.txt 語法分析程序http
--- HTTP 模塊http.client
--- HTTP 協議客戶端ftplib
--- FTP 協議客戶端poplib
--- POP3 protocol clientimaplib
--- IMAP4 protocol clientnntplib
--- NNTP protocol clientsmtplib
---SMTP協議客戶端smtpd
--- SMTP 服務器telnetlib
--- Telnet clientuuid
--- UUID objects according to RFC 4122socketserver
--- A framework for network servershttp.server
--- HTTP 服務器http.cookies
--- HTTP狀態管理http.cookiejar
—— HTTP 客戶端的 Cookie 處理xmlrpc
--- XMLRPC 服務端與客戶端模塊xmlrpc.client
--- XML-RPC client accessxmlrpc.server
--- Basic XML-RPC serversipaddress
--- IPv4/IPv6 manipulation library
- 多媒體服務
- 國際化
- 程序框架
- Tk圖形用戶界面(GUI)
- 開發工具
typing
--- 類型標註支持pydoc
--- Documentation generator and online help systemdoctest
--- 測試交互性的Python示例unittest
--- 單元測試框架unittest.mock
--- mock對象庫unittest.mock
上手指南- 2to3 - 自動將 Python 2 代碼轉爲 Python 3 代碼
test
--- Regression tests package for Pythontest.support
--- Utilities for the Python test suitetest.support.script_helper
--- Utilities for the Python execution tests
- 調試和分析
- 軟件打包和分發
- Python運行時服務
sys
--- 系統相關的參數和函數sysconfig
--- Provide access to Python's configuration informationbuiltins
--- 內建對象__main__
--- 頂層腳本環境warnings
--- Warning controldataclasses
--- 數據類contextlib
--- Utilities forwith
-statement contextsabc
--- 抽象基類atexit
--- 退出處理器traceback
--- 打印或檢索堆棧回溯__future__
--- Future 語句定義gc
--- 垃圾回收器接口inspect
--- 檢查對象site
--- Site-specific configuration hook
- 自定義 Python 解釋器
- 導入模塊
- Python 語言服務
parser
--- Access Python parse treesast
--- 抽象語法樹symtable
--- Access to the compiler's symbol tablessymbol
--- 與 Python 解析樹一起使用的常量token
--- 與Python解析樹一起使用的常量keyword
--- 檢驗Python關鍵字tokenize
--- Tokenizer for Python sourcetabnanny
--- 模糊縮進檢測pyclbr
--- Python class browser supportpy_compile
--- Compile Python source filescompileall
--- Byte-compile Python librariesdis
--- Python 字節碼反彙編器pickletools
--- Tools for pickle developers
- 雜項服務
- Windows系統相關模塊
- Unix 專有服務
posix
--- The most common POSIX system callspwd
--- 用戶密碼數據庫spwd
--- The shadow password databasegrp
--- The group databasecrypt
--- Function to check Unix passwordstermios
--- POSIX style tty controltty
--- 終端控制功能pty
--- Pseudo-terminal utilitiesfcntl
--- Thefcntl
andioctl
system callspipes
--- Interface to shell pipelinesresource
--- Resource usage informationnis
--- Interface to Sun's NIS (Yellow Pages)- Unix syslog 庫例程
- 被取代的模塊
- 未創建文檔的模塊