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 ...
随机推荐
- 图(graph)
一.非线性结构:图 图由顶点集V,集合规模为n,在n个顶点之间可能存在对应关系,我们用连边来描述这种,即边E,规模为e. 邻接关系:顶点与顶点之间的关系:关联关系:顶点与它相连的边的关系.序列结构(v ...
- 【SPOJ DQUERY】区间数字统计
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 因为区间的端点移动一个单位的话,只会涉及到一个元素的增多或减少. 因此可以用莫队算法来解决. 只需要开一个数组(大小1百万),用下标来快速检索 ...
- 后缀自动机模板——不同子串个数p2408
后缀自动机的入门博客 https://www.luogu.org/blog/Kesdiael3/hou-zhui-zi-dong-ji-yang-xie 有两种求法,分别对应了两种性质 #includ ...
- NX二次开发-UFUN工程图表格注释获取某一行的tag函数UF_TABNOT_ask_nth_row
NX9+VS2012 #include <uf.h> #include <uf_tabnot.h> #include <NXOpen/Part.hxx> #incl ...
- NX二次开发-UFUN创建图层类别UF_LAYER_create_category
NX11+VS2013 #include <uf.h> #include <uf_layer.h> UF_initialize(); //创建图层类别 UF_LAYER_cat ...
- NX二次开发-删除经典工具栏UF_UI_remove_toolbar
NX9+VS2012 1.打开D:\Program Files\Siemens\NX 9.0\UGII\menus\ug_main.men 找到装配和PMI,在中间加上一段 TOGGLE_BUTTON ...
- Mac OS 快速查询技巧
今天不知道按到什么快捷键弹出了这个搜索框,试了试很强大 后来查了才知道要双击键盘上的key (⌘)就会弹出,这个搜索很强大,要先安装QQ,QQ自带的 版权声明:本文为博主原创文章,未经博主允许不得转载 ...
- RTC, Real Time Clock
配置 写入RTC_PRL, RTC_CNT, RTC_ALR寄存器时,需要先进入配置模式,通过把RTC_CRL寄存器的CNF位置一. 另外,在每次配置一个寄存器时必须等待上一次配置完成,可以通过检测R ...
- Comet OJ - 2019 六一欢乐赛
传送门 #A: 思路:等差数列求和,看成俩次1+2+…+ n,多加的n减去,所以 ans = n*(n+1) - n. AC代码: #include<iostream> #include& ...
- 绿色版mysql 免安装使用(转载)
MySQL绿色版的安装(mysql-5.6.22-win32.zip) Posted on 2015-01-31 23:21 卒子 阅读(10739) 评论(2) 编辑 收藏 由于工作需要最近要开始研 ...