The Python Standard Library
The Python Standard Library¶
While The Python Language Reference 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.
In addition to the standard library, there is a growing collection of
several thousand components (from individual programs and modules to
packages and entire application development frameworks), available from
the Python Package Index.
- 1. Introduction
- 2. Built-in Functions
- 3. Built-in Constants
- 4. Built-in Types
- 4.1. Truth Value Testing
- 4.2. Boolean Operations —
and,or,not - 4.3. Comparisons
- 4.4. Numeric Types —
int,float,complex - 4.5. Iterator Types
- 4.6. Sequence Types —
list,tuple,range - 4.7. Text Sequence Type —
str - 4.8. Binary Sequence Types —
bytes,bytearray,memoryview - 4.9. Set Types —
set,frozenset - 4.10. Mapping Types —
dict - 4.11. Context Manager Types
- 4.12. Other Built-in Types
- 4.13. Special Attributes
- 5. Built-in Exceptions
- 6. Text Processing Services
- 6.1.
string— Common string operations - 6.2.
re— Regular expression operations - 6.3.
difflib— Helpers for computing deltas - 6.4.
textwrap— Text wrapping and filling - 6.5.
unicodedata— Unicode Database - 6.6.
stringprep— Internet String Preparation - 6.7.
readline— GNU readline interface - 6.8.
rlcompleter— Completion function for GNU readline
- 6.1.
- 7. Binary Data Services
- 8. Data Types
- 8.1.
datetime— Basic date and time types - 8.2.
calendar— General calendar-related functions - 8.3.
collections— Container datatypes - 8.4.
collections.abc— Abstract Base Classes for Containers - 8.5.
heapq— Heap queue algorithm - 8.6.
bisect— Array bisection algorithm - 8.7.
array— Efficient arrays of numeric values - 8.8.
weakref— Weak references - 8.9.
types— Dynamic type creation and names for built-in types - 8.10.
copy— Shallow and deep copy operations - 8.11.
pprint— Data pretty printer - 8.12.
reprlib— Alternaterepr()implementation - 8.13.
enum— Support for enumerations
- 8.1.
- 9. Numeric and Mathematical Modules
- 9.1.
numbers— Numeric abstract base classes - 9.2.
math— Mathematical functions - 9.3.
cmath— Mathematical functions for complex numbers - 9.4.
decimal— Decimal fixed point and floating point arithmetic - 9.5.
fractions— Rational numbers - 9.6.
random— Generate pseudo-random numbers - 9.7.
statistics— Mathematical statistics functions
- 9.1.
- 10. Functional Programming Modules
- 11. File and Directory Access
- 11.1.
pathlib— Object-oriented filesystem paths - 11.2.
os.path— Common pathname manipulations - 11.3.
fileinput— Iterate over lines from multiple input streams - 11.4.
stat— Interpretingstat()results - 11.5.
filecmp— File and Directory Comparisons - 11.6.
tempfile— Generate temporary files and directories - 11.7.
glob— Unix style pathname pattern expansion - 11.8.
fnmatch— Unix filename pattern matching - 11.9.
linecache— Random access to text lines - 11.10.
shutil— High-level file operations - 11.11.
macpath— Mac OS 9 path manipulation functions
- 11.1.
- 12. Data Persistence
- 13. Data Compression and Archiving
- 14. File Formats
- 15. Cryptographic Services
- 16. Generic Operating System Services
- 16.1.
os— Miscellaneous operating system interfaces - 16.2.
io— Core tools for working with streams - 16.3.
time— Time access and conversions - 16.4.
argparse— Parser for command-line options, arguments and sub-commands - 16.5.
getopt— C-style parser for command line options - 16.6.
logging— Logging facility for Python - 16.7.
logging.config— Logging configuration - 16.8.
logging.handlers— Logging handlers - 16.9.
getpass— Portable password input - 16.10.
curses— Terminal handling for character-cell displays - 16.11.
curses.textpad— Text input widget for curses programs - 16.12.
curses.ascii— Utilities for ASCII characters - 16.13.
curses.panel— A panel stack extension for curses - 16.14.
platform— Access to underlying platform’s identifying data - 16.15.
errno— Standard errno system symbols - 16.16.
ctypes— A foreign function library for Python
- 16.1.
- 17. Concurrent Execution
- 17.1.
threading— Thread-based parallelism - 17.2.
multiprocessing— Process-based parallelism - 17.3. The
concurrentpackage - 17.4.
concurrent.futures— Launching parallel tasks - 17.5.
subprocess— Subprocess management - 17.6.
sched— Event scheduler - 17.7.
queue— A synchronized queue class - 17.8.
_thread— Low-level threading API - 17.9.
_dummy_thread— Drop-in replacement for the_threadmodule - 17.10.
dummy_threading— Drop-in replacement for thethreadingmodule
- 17.1.
- 18.
contextvars— Context Variables - 19. Interprocess Communication and Networking
- 19.1.
socket— Low-level networking interface - 19.2.
ssl— TLS/SSL wrapper for socket objects - 19.3.
select— Waiting for I/O completion - 19.4.
selectors— High-level I/O multiplexing - 19.5.
asyncio— Asynchronous I/O, event loop, coroutines and tasks - 19.6.
asyncore— Asynchronous socket handler - 19.7.
asynchat— Asynchronous socket command/response handler - 19.8.
signal— Set handlers for asynchronous events - 19.9.
mmap— Memory-mapped file support
- 19.1.
- 20. Internet Data Handling
- 20.1.
email— An email and MIME handling package - 20.2.
json— JSON encoder and decoder - 20.3.
mailcap— Mailcap file handling - 20.4.
mailbox— Manipulate mailboxes in various formats - 20.5.
mimetypes— Map filenames to MIME types - 20.6.
base64— Base16, Base32, Base64, Base85 Data Encodings - 20.7.
binhex— Encode and decode binhex4 files - 20.8.
binascii— Convert between binary and ASCII - 20.9.
quopri— Encode and decode MIME quoted-printable data - 20.10.
uu— Encode and decode uuencode files
- 20.1.
- 21. Structured Markup Processing Tools
- 21.1.
html— HyperText Markup Language support - 21.2.
html.parser— Simple HTML and XHTML parser - 21.3.
html.entities— Definitions of HTML general entities - 21.4. XML Processing Modules
- 21.5.
xml.etree.ElementTree— The ElementTree XML API - 21.6.
xml.dom— The Document Object Model API - 21.7.
xml.dom.minidom— Minimal DOM implementation - 21.8.
xml.dom.pulldom— Support for building partial DOM trees - 21.9.
xml.sax— Support for SAX2 parsers - 21.10.
xml.sax.handler— Base classes for SAX handlers - 21.11.
xml.sax.saxutils— SAX Utilities - 21.12.
xml.sax.xmlreader— Interface for XML parsers - 21.13.
xml.parsers.expat— Fast XML parsing using Expat
- 21.1.
- 22. Internet Protocols and Support
- 22.1.
webbrowser— Convenient Web-browser controller - 22.2.
cgi— Common Gateway Interface support - 22.3.
cgitb— Traceback manager for CGI scripts - 22.4.
wsgiref— WSGI Utilities and Reference Implementation - 22.5.
urllib— URL handling modules - 22.6.
urllib.request— Extensible library for opening URLs - 22.7.
urllib.response— Response classes used by urllib - 22.8.
urllib.parse— Parse URLs into components - 22.9.
urllib.error— Exception classes raised by urllib.request - 22.10.
urllib.robotparser— Parser for robots.txt - 22.11.
http— HTTP modules - 22.12.
http.client— HTTP protocol client - 22.13.
ftplib— FTP protocol client - 22.14.
poplib— POP3 protocol client - 22.15.
imaplib— IMAP4 protocol client - 22.16.
nntplib— NNTP protocol client - 22.17.
smtplib— SMTP protocol client - 22.18.
smtpd— SMTP Server - 22.19.
telnetlib— Telnet client - 22.20.
uuid— UUID objects according to RFC 4122 - 22.21.
socketserver— A framework for network servers - 22.22.
http.server— HTTP servers - 22.23.
http.cookies— HTTP state management - 22.24.
http.cookiejar— Cookie handling for HTTP clients - 22.25.
xmlrpc— XMLRPC server and client modules - 22.26.
xmlrpc.client— XML-RPC client access - 22.27.
xmlrpc.server— Basic XML-RPC servers - 22.28.
ipaddress— IPv4/IPv6 manipulation library
- 22.1.
- 23. Multimedia Services
- 23.1.
audioop— Manipulate raw audio data - 23.2.
aifc— Read and write AIFF and AIFC files - 23.3.
sunau— Read and write Sun AU files - 23.4.
wave— Read and write WAV files - 23.5.
chunk— Read IFF chunked data - 23.6.
colorsys— Conversions between color systems - 23.7.
imghdr— Determine the type of an image - 23.8.
sndhdr— Determine type of sound file - 23.9.
ossaudiodev— Access to OSS-compatible audio devices
- 23.1.
- 24. Internationalization
- 25. Program Frameworks
- 26. Graphical User Interfaces with Tk
- 27. Development Tools
- 27.1.
typing— Support for type hints - 27.2.
pydoc— Documentation generator and online help system - 27.3.
doctest— Test interactive Python examples - 27.4.
unittest— Unit testing framework - 27.5.
unittest.mock— mock object library - 27.6.
unittest.mock— getting started - 27.7. 2to3 - Automated Python 2 to 3 code translation
- 27.8.
test— Regression tests package for Python - 27.9.
test.support— Utilities for the Python test suite - 27.10.
test.support.script_helper— Utilities for the Python execution tests
- 27.1.
- 28. Debugging and Profiling
- 29. Software Packaging and Distribution
- 30. Python Runtime Services
- 30.1.
sys— System-specific parameters and functions - 30.2.
sysconfig— Provide access to Python’s configuration information - 30.3.
builtins— Built-in objects - 30.4.
__main__— Top-level script environment - 30.5.
warnings— Warning control - 30.6.
dataclasses— Data Classes - 30.7.
contextlib— Utilities forwith-statement contexts - 30.8.
abc— Abstract Base Classes - 30.9.
atexit— Exit handlers - 30.10.
traceback— Print or retrieve a stack traceback - 30.11.
__future__— Future statement definitions - 30.12.
gc— Garbage Collector interface - 30.13.
inspect— Inspect live objects - 30.14.
site— Site-specific configuration hook
- 30.1.
- 31. Custom Python Interpreters
- 32. Importing Modules
- 33. Python Language Services
- 33.1.
parser— Access Python parse trees - 33.2.
ast— Abstract Syntax Trees - 33.3.
symtable— Access to the compiler’s symbol tables - 33.4.
symbol— Constants used with Python parse trees - 33.5.
token— Constants used with Python parse trees - 33.6.
keyword— Testing for Python keywords - 33.7.
tokenize— Tokenizer for Python source - 33.8.
tabnanny— Detection of ambiguous indentation - 33.9.
pyclbr— Python class browser support - 33.10.
py_compile— Compile Python source files - 33.11.
compileall— Byte-compile Python libraries - 33.12.
dis— Disassembler for Python bytecode - 33.13.
pickletools— Tools for pickle developers
- 33.1.
- 34. Miscellaneous Services
- 35. MS Windows Specific Services
- 36. Unix Specific Services
- 36.1.
posix— The most common POSIX system calls - 36.2.
pwd— The password database - 36.3.
spwd— The shadow password database - 36.4.
grp— The group database - 36.5.
crypt— Function to check Unix passwords - 36.6.
termios— POSIX style tty control - 36.7.
tty— Terminal control functions - 36.8.
pty— Pseudo-terminal utilities - 36.9.
fcntl— Thefcntlandioctlsystem calls - 36.10.
pipes— Interface to shell pipelines - 36.11.
resource— Resource usage information - 36.12.
nis— Interface to Sun’s NIS (Yellow Pages) - 36.13.
syslog— Unix syslog library routines
- 36.1.
- 37. Superseded Modules
- 38. Undocumented Modules
转自:
The Python Standard Library — Python 3.7.0 documentation
https://docs.python.org/3/library/index.html
The Python Standard Library的更多相关文章
- Python语言中对于json数据的编解码——Usage of json a Python standard library
一.概述 1.1 关于JSON数据格式 JSON (JavaScript Object Notation), specified by RFC 7159 (which obsoletes RFC 46 ...
- Python Standard Library
Python Standard Library "We'd like to pretend that 'Fredrik' is a role, but even hundreds of vo ...
- 《The Python Standard Library》——http模块阅读笔记1
官方文档:https://docs.python.org/3.5/library/http.html 偷个懒,截图如下: 即,http客户端编程一般用urllib.request库(主要用于“在这复杂 ...
- 《The Python Standard Library》——http模块阅读笔记2
http.server是用来构建HTTP服务器(web服务器)的模块,定义了许多相关的类. 创建及运行服务器的代码一般为: def run(server_class=HTTPServer, handl ...
- Python Standard Library 学习(一) -- Built-in Functions 内建函数
内建函数列表 Built-in Functions abs() divmod() input() open() staticmethod() all() enumerate() int() ord() ...
- 《The Python Standard Library》——http模块阅读笔记3
http.cookies — HTTP state management http.cookies模块定义了一系列类来抽象cookies这个概念,一个HTTP状态管理机制.该模块支持string-on ...
- [译]The Python Tutorial#11. Brief Tour of the Standard Library — Part II
[译]The Python Tutorial#Brief Tour of the Standard Library - Part II 第二部分介绍更多满足专业编程需求的高级模块,这些模块在小型脚本中 ...
- [译]The Python Tutorial#10. Brief Tour of the Standard Library
[译]The Python Tutorial#Brief Tour of the Standard Library 10.1 Operating System Interface os模块为与操作系统 ...
- CentOS 6.5 Python Image Library 配置
转自:http://www.cnblogs.com/way_testlife/archive/2011/04/17/2019013.html PIL 下载: http://www.pythonware ...
随机推荐
- python_django_template模块
官方文档 博文导航: 定义模板: 变量 标签: if for include url csrf_token 过滤器: 简单过滤器 HTML转义 加减乘除的过滤器 注释: 模板继承 模板语言:Dja ...
- pandas的read_csv踩到的坑
read_csv要注意,如果没有设置index_col时,读出来的会在索引上方加上Unnamed:0.可以通过设置index_col来解决这个问题. import pandas as pd impor ...
- 每天进步一点点-Tesseract 文字识别
Tesseract 文字识别 是github上的开源文字识别软件 下载与安装 https://github.com/tesseract-ocr/tesseract/wiki 下载 https://gi ...
- Java 导出excel进行换行
在导出excel 的时候,如果原始文字中含有 \n 字符,生成的excel中 会生成 _0040_ 字样的乱码, 如果把 \n 替换为<br/>,excel不会识别成换行符 excel 认 ...
- TTreeView、TTreeNodes和TTreeNode
TreeView是Delphi中使用频率比较高的一个控件,虽然使用次数很多,但总结不够.借着这次做GDW原型的机会总结一下,写的过程中也会参考网上的博文. TTreeView.TTreeNodes和T ...
- 【历年真题】斐波那契数列logn做法
描述 [题解] 用矩阵乘法加速递推 [0 1] [1 1] [f[n-1]] [f[n-2]] = [f[n-1]] [f[n]] 求A矩阵的n-2次幂然后再乘B矩阵. 结果矩阵中的第二行第一列就是f ...
- hdu6606多校第四次04——线段树加速dp
/* 首先想到二分答案,难点在于如何判断是否有K段,每段和<=mid 把问题转化成求最多有R段,最少有L段,每段的的和<=mid,如果 L<=K<=R 那么显然存在把这个序列分 ...
- 约数个数求和+线性筛约数——bzoj3994
这题首先要会线性筛约数个数,并求出前缀和 bool vis[maxn]; int mm,mu[maxn],prime[maxn],num[maxn],sum[maxn],d[maxn],sum1[ma ...
- 27 和为S的两个数字
0 引言 题目描述:输入一个递增排序的数组和一个数字S,在数组中查找两个数,使得他们的和正好是S,如果有多对数字的和等于S,输出两个数的乘积最小的. 1 抽象问题具体化 举例: 序列为{1,2,3,4 ...
- Linux命令(1):date
查看时间: date "+%Y-%m-%d %H:%M:%S" 参数说明: %n : 下一行 %t : 跳格 %H : 小时(00..23) %I : 小时(01..12) %k ...