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 ...
随机推荐
- scip 练习2.18
(define (append a b ) (if (null? a )b (cons (car a) (append (cdr a) b)))) (define (reverse l) (appen ...
- nodejs 模板引擎ejs的简单使用(2)
test.ejs <!DOCTYPE html> <html> <head> <meta charset="utf-8"> < ...
- Ruby 环境变量
Ruby 环境变量 Ruby 解释器使用下列环境变量来控制它的行为.ENV 对象包含了所有当前设置的环境变量列表. 变量 描述 DLN_LIBRARY_PATH 动态加载模块搜索的路径. HOME 当 ...
- 2018-06-05(thinking in java)
1:类只能有2种访问权限,一种是不写访问权限:默认包访问权限,另一种是public.且类只能有一个pubic 2:方法有4种访问权限,pubic(都可以访问),protexted(继承访问权限),pr ...
- class10_Frame 框架
最终运行效果图(程序见序号2): #!/usr/bin/env python # -*- coding:utf-8 -*- # ---------------------------------- ...
- sql2000行转列 转过来的测试完也不知那个网站去哪了 没法写出处了
ALTER procedure dbo.CommonRowToCol ) as begin --必须包含colname列和result列(不区分大小写), --除colname列和result列 其余 ...
- sklearn算法中的顶层设计
sklearn监督学习的各个模块 neighbors近邻算法,svm支持向量机,kernal_ridge核岭回归,discriminant_analysis判别分析,linear_model广义线性模 ...
- 15-Ubuntu-文件和目录命令-查看目录内容-ls-2
4. ls和通配符的使用 通配符适用的地方:shell命令行或者shell脚本中. 正则表达式适用的地方:字符串处理时,一般有一般正则和Perl正则. 正则表达式与通配符有相同的符号但是意义不同!! ...
- 【POJ】3660 Cow Contest
题目链接:http://poj.org/problem?id=3660 题意:n头牛比赛,有m场比赛,两两比赛,前面的就是赢家.问你能确认几头牛的名次. 题解:首先介绍个东西,传递闭包,它可以确定尽可 ...
- Js_案例(电灯)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...