While Python 语言参考 describes the exact syntax and semantics of the Python language, this library reference manual describes the standard library that is distributed with Python. It also describes some of the optional components that are commonly included in Python distributions.
Python’s standard library is very 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.
The Python installers for the Windows platform usually include the entire standard library and often also include many additional components. For Unix-like operating systems Python is normally provided as a collection of packages, so it may be necessary to use the packaging tools provided with the operating system to obtain some or all of the optional components.
除标准库外,还有不断增长由数千个组件组成的集合 (从单独的程序和模块到包,及整个应用程序开发框架),可以获得从 PyPI (Python 包索引) .
datetime
— 基本日期 时间类型
calendar
— 一般日历相关功能
collections
— 容器数据类型
collections.abc
— 容器抽象基类
heapq
— 堆队列算法
bisect
— 数组二分算法
array
— 高效数值数组
weakref
— 弱引用
types
— 动态类型创建和内置类型的名称
copy
— 浅拷贝和深拷贝操作
pprint
— 数据漂亮打印机
reprlib
— 替代
repr()
实现
enum
— 支持枚举
os
— 杂项操作系统接口
io
— 用于处理流的核心工具
time
— 时间的访问和转换
argparse
— 用于命令行选项 自变量和子命令的剖析器
getopt
— 用于命令行选项的 C 样式剖析器
logging
— 用于的 Python 日志设施
logging.config
— 日志配置
logging.handlers
— 日志处理程序
getpass
— 便携式口令输入
curses
— 用于字符单元显示的终端处理
curses.textpad
— 用于 curses 程序的文本输入 Widget
curses.ascii
— 用于 ASCII 字符的实用程序
curses.panel
— 用于 curses 的面板堆栈扩展
platform
— 访问底层平台的标识数据
errno
— 标准 errno 系统符号
ctypes
— 用于 Python 的外来函数库
email
— Email 和 MIME 处理包
json
— JSON 编码器和解码器
mailcap
— Mailcap 文件处理
mailbox
— 操纵各种格式的邮箱
mimetypes
— 把文件名映射到 MIME 类型
base64
— Base16 Base32 Base64 Base85 数据编码
binhex
— 编码和解码 binhex4 文件
binascii
— 在二进制和 ASCII 之间转换
quopri
— 编码和解码 MIME 带引号可打印数据
uu
— 编码和解码 uuencode 文件
html
— HTML (超文本标记语言) 支持
html.parser
— 简单 HTML 和 XHTML 剖析器
html.entities
— HTML 一般实体的定义
xml.etree.ElementTree
— ElementTree XML API
xml.dom
— DOM (文档对象模型) API
xml.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
— 方便的 Web 浏览器控制器
cgi
— 通用网关接口支持
cgitb
— CGI 脚本的回溯管理器
wsgiref
— WSGI 实用程序和参考实现
urllib
— URL 处理模块
urllib.request
— 用于打开 URL 的可扩展库
urllib.response
— 用于 urllib 的响应类
urllib.parse
— 把 URL 剖析成组件
urllib.error
— 由 urllib.request 引发的异常类
urllib.robotparser
— robots.txt 剖析器
http
— HTTP 模块
http.client
— HTTP 协议客户端
ftplib
— FTP 协议客户端
poplib
— POP3 协议客户端
imaplib
— IMAP4 协议客户端
nntplib
— NNTP 协议客户端
smtplib
— SMTP 协议客户端
smtpd
— SMTP 服务器
telnetlib
— Telnet 客户端
uuid
— UUID 对象根据
RFC 4122
socketserver
— 网络服务器框架
http.server
— HTTP 服务器
http.cookies
— HTTP 状态管理
http.cookiejar
— 用于 HTTP 客户端的 Cookie 处理
xmlrpc
— XMLRPC 服务器和客户端模块
xmlrpc.client
— XML-RPC 客户端访问
xmlrpc.server
— 基本 XML-RPC 服务器
ipaddress
— IPv4/IPv6 操纵库
sys
— 特定系统参数和函数
sysconfig
— 提供对 Python 配置信息的访问
builtins
— 内容对象
__main__
— 顶层脚本环境
warnings
— 警告控制
contextlib
— 实用程序为
with
语句上下文
abc
— 抽象基类
atexit
— 退出处理程序
traceback
— 打印或检索堆栈回溯
__future__
— 未来的语句定义
gc
— 垃圾收集器接口
inspect
— 审查活对象
site
— 特定站点配置挂钩
fpectl
— 浮点异常控制
parser
— 访问 Python 剖析树
ast
— 抽象句法树
symtable
— 访问编译器的符号表
symbol
— 用于 Python 剖析树的常量
token
— 用于 Python 剖析树的常量
keyword
— 测试 Python 关键字
tokenize
— 用于 Python 源代码的 Tokenizer
tabnanny
— 歧义缩进的检测
pyclbr
— Python 类浏览器支持
py_compile
— 编译 Python 源文件
compileall
— 字节编译 Python 库
dis
— 用于 Python 字节码的反汇编程序
pickletools
— 用于腌制开发者的工具
posix
— 最常见的 POSIX 系统调用
pwd
— 口令数据库
spwd
— 影子口令数据库
grp
— 组数据库
crypt
— 校验 Unix 密码的函数
termios
— POSIX 样式 tty 控制
tty
— 终端控制函数
pty
— 伪终端实用程序
fcntl
—
fcntl
and
ioctl
系统调用
pipes
— Shell 管道接口
resource
— 资源使用信息
nis
— 接口到 Sun 的 NIS (黄页)
syslog
— Unix syslog 库例程