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 ...
随机推荐
- C++11的闭包(lambda、function、bind)
c++11开始支持闭包,闭包:与函数A调用函数B相比较,闭包中函数A调用函数B,可以不通过函数A给函数B传递函数参数,而使函数B可以访问函数A的上下文环境才可见(函数A可直接访问到)的变量:比如: 函 ...
- [原创] delphi Memo 滚动到底部/开始 [Delphi XE、Delphi 7]
以前控制Memo滚动到底部的操作: SendMessage(memo1.Handle,WM_VSCROLL,SB_BOTTOM,0); 或者 Memo1.SelLength:=Length(Memo1 ...
- Delphi ADOQuery
Delphi ADOQuery procedure TForm1.Button1Click(Sender: TObject); var A: Array of String;//定义动态数组 Inde ...
- vue-cli整合axios的几种方法
Vue这个框架现在在单页面应用方面非常受人欢迎. 基于vue-cli创建的项目怎么样才能更好地处理网络请求? 首选的应该就是axios了 这次给刚接触vue的新手介绍一下axios在vue中如何使用 ...
- BZOJ3211花神游历各国-线段树&树状数组-(HDU4027同类型)
(有任何问题欢迎留言或私聊 && 欢迎交流讨论哦 题意:BZOJ HDU 原题目描述在最下面. 两种操作,1:把区间的数字开方一次,2:区间求和. 思路: 线段树: 显然不能暴力 ...
- sqlalchemy session
Cookie cookie是浏览器保存在用户电脑上的一小段文本,用来保存用户在网站上的必要的信息.Web页面或服务器告诉浏览器按照一定的规范存储这些信息,并且在以后的所有请求中,这些信息就会自动加在h ...
- sql中desc的妙用
很多情况下对表内部结构不熟悉,想看下我创建的表里面又多少表明,又想他按照首字母的规律排列, 这时候就要用desc +表名了. desc t_bike_info; hive> desc t_bik ...
- HDU-1850-Being a Good Boy in Spring Festival-nim博弈
一年在外 父母时刻牵挂春节回家 你能做几天好孩子吗寒假里尝试做做下面的事情吧 陪妈妈逛一次菜场悄悄给爸爸买个小礼物主动地 强烈地 要求洗一次碗某一天早起 给爸妈用心地做回早餐 如果愿意 你还可以和爸妈 ...
- Spark 调优之ShuffleManager、Shuffle
Shuffle 概述 影响Spark性能的大BOSS就是shuffle,因为该环节包含了大量的磁盘IO.序列化.网络数据传输等操作. 因此,如果要让作业的性能更上一层楼,就有必要对 shuffle 过 ...
- DRF的序列化组件
目录 DRF的序列化组件 Serializer组件 序列化 反序列化 ModelSerializer组件 序列化和反序列化 自定义Response方法 基表相关 DRF中ORM的多表关联操作 外键设计 ...