Python 標準函式庫 (Standard Library)
************************************

The Python Language Reference 說明 Python 這門語言確切的文法及語意，而
這份函式庫參考手冊則是說明隨著 Python 一起發佈的標準函式庫，除此之外，
其內容也包含一些時常出現在 Python 發佈版本中的非必要套件。

Python 的標準函式庫是非常龐大的，其提供了如下所述極多且涵蓋用途極廣的
許多模組。包含一些用 C 語言撰寫，可以操作像是檔案讀寫等系統相關功能的
內建模組，當然也有用 Python 撰寫，並使用標準解法解決許多常見問題的模組
。其中有些模組則是特別針對 Python 的可攜性去設計的，為此特地將一些平台
特殊相依性的功能抽象化成可跨平台的 API。

Python 的 Windows 安裝檔基本上包含整個標準函式庫，且通常也包含許多額外
套件；而類 Unix 作業系統方面，Python 則提供一系列的套件，對於某些非必
要性的套件，可能得使用該作業系統提供的套件管理工具來安裝。

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.

* 簡介

  * Notes on availability

* 內建函式

* 內建常數

  * Constants added by the "site" module

* 內建型態

  * Truth Value Testing

  * 布尔运算 --- "and", "or", "not"

  * Comparisons

  * Numeric Types --- "int", "float", "complex"

  * Iterator Types

  * Sequence Types --- "list", "tuple", "range"

  * Text Sequence Type --- "str"

  * Binary Sequence Types --- "bytes", "bytearray", "memoryview"

  * Set Types --- "set", "frozenset"

  * Mapping Types --- "dict"

  * Context Manager Types

  * Other Built-in Types

  * Special Attributes

* 內建的例外

  * Base classes

  * Concrete exceptions

  * Warnings

  * Exception hierarchy

* Text Processing Services

  * "string" --- Common string operations

  * "re" --- Regular expression operations

  * "difflib" --- Helpers for computing deltas

  * "textwrap" --- Text wrapping and filling

  * "unicodedata" --- Unicode Database

  * "stringprep" --- Internet String Preparation

  * "readline" --- GNU readline interface

  * "rlcompleter" --- Completion function for GNU readline

* Binary Data Services

  * "struct" --- Interpret bytes as packed binary data

  * "codecs" --- Codec registry and base classes

* Data Types

  * "datetime" --- Basic date and time types

  * "calendar" --- General calendar-related functions

  * "collections" --- 容器資料型態

  * "collections.abc" --- Abstract Base Classes for Containers

  * "heapq" --- 堆積佇列 (heap queue) 演算法

  * "bisect" --- 陣列二分演算法 (Array bisection algorithm)

  * "array" --- 高效率的數值型態陣列

  * "weakref" --- Weak references

  * "types" --- Dynamic type creation and names for built-in types

  * "copy" --- Shallow and deep copy operations

  * "pprint" --- Data pretty printer

  * "reprlib" --- Alternate "repr()" implementation

  * "enum" --- Support for enumerations

* 數值與數學模組

  * "numbers" --- Numeric abstract base classes

  * "math" --- Mathematical functions

  * "cmath" --- Mathematical functions for complex numbers

  * "decimal" --- Decimal fixed point and floating point arithmetic

  * "fractions" --- Rational numbers

  * "random" --- Generate pseudo-random numbers

  * "statistics" --- 數學統計函式

* 函式編程模組

  * "itertools" --- Functions creating iterators for efficient
    looping

  * "functools" --- Higher-order functions and operations on
    callable objects

  * "operator" --- Standard operators as functions

* 檔案與目錄存取

  * "pathlib" --- Object-oriented filesystem paths

  * "os.path" --- Common pathname manipulations

  * "fileinput" --- Iterate over lines from multiple input streams

  * "stat" --- Interpreting "stat()" results

  * "filecmp" --- File and Directory Comparisons

  * "tempfile" --- Generate temporary files and directories

  * "glob" --- Unix style pathname pattern expansion

  * "fnmatch" --- Unix filename pattern matching

  * "linecache" --- Random access to text lines

  * "shutil" --- High-level file operations

* Data Persistence

  * "pickle" --- Python object serialization

  * "copyreg" --- Register "pickle" support functions

  * "shelve" --- Python object persistence

  * "marshal" --- Internal Python object serialization

  * "dbm" --- Interfaces to Unix "databases"

  * "sqlite3" --- DB-API 2.0 interface for SQLite databases

* 資料壓縮與保存

  * "zlib" --- Compression compatible with **gzip**

  * "gzip" --- Support for **gzip** files

  * "bz2" --- Support for **bzip2** compression

  * "lzma" --- Compression using the LZMA algorithm

  * "zipfile" --- Work with ZIP archives

  * "tarfile" --- Read and write tar archive files

* 檔案格式

  * "csv" --- CSV File Reading and Writing

  * "configparser" --- Configuration file parser

  * "netrc" --- netrc file processing

  * "xdrlib" --- Encode and decode XDR data

  * "plistlib" --- Generate and parse Mac OS X ".plist" files

* Cryptographic Services

  * "hashlib" --- Secure hashes and message digests

  * "hmac" --- Keyed-Hashing for Message Authentication

  * "secrets" --- Generate secure random numbers for managing
    secrets

* Generic Operating System Services

  * "os" --- Miscellaneous operating system interfaces

  * "io" --- Core tools for working with streams

  * "time" --- Time access and conversions

  * "argparse" --- Parser for command-line options, arguments and
    sub- commands

  * "getopt" --- C-style parser for command line options

  * "logging" --- Logging facility for Python

  * "logging.config" --- Logging configuration

  * "logging.handlers" --- Logging handlers

  * "getpass" --- Portable password input

  * "curses" --- Terminal handling for character-cell displays

  * "curses.textpad" --- Text input widget for curses programs

  * "curses.ascii" --- Utilities for ASCII characters

  * "curses.panel" --- A panel stack extension for curses

  * "platform" ---  Access to underlying platform's identifying data

  * "errno" --- Standard errno system symbols

  * "ctypes" --- A foreign function library for Python

* Concurrent Execution

  * "threading" --- Thread-based parallelism

  * "multiprocessing" --- Process-based parallelism

  * "multiprocessing.shared_memory" ---  Provides shared memory for
    direct access across processes

  * The "concurrent" package

  * "concurrent.futures" --- Launching parallel tasks

  * "subprocess" --- Subprocess management

  * "sched" --- Event scheduler

  * "queue" --- A synchronized queue class

  * "_thread" --- Low-level threading API

  * "_dummy_thread" --- Drop-in replacement for the "_thread" module

  * "dummy_threading" --- Drop-in replacement for the "threading"
    module

* "contextvars" --- Context Variables

  * Context Variables

  * Manual Context Management

  * asyncio support

* Networking and Interprocess Communication

  * "asyncio" --- Asynchronous I/O

  * "socket" --- Low-level networking interface

  * "ssl" --- TLS/SSL wrapper for socket objects

  * "select" --- Waiting for I/O completion

  * "selectors" --- High-level I/O multiplexing

  * "asyncore" --- Asynchronous socket handler

  * "asynchat" --- Asynchronous socket command/response handler

  * "signal" --- Set handlers for asynchronous events

  * "mmap" --- Memory-mapped file support

* Internet Data Handling

  * "email" --- An email and MIME handling package

  * "json" --- JSON encoder and decoder

  * "mailcap" --- Mailcap file handling

  * "mailbox" --- Manipulate mailboxes in various formats

  * "mimetypes" --- Map filenames to MIME types

  * "base64" —— Base16、Base32、Base64、Base85 資料編碼

  * "binhex" --- Encode and decode binhex4 files

  * "binascii" --- Convert between binary and ASCII

  * "quopri" --- Encode and decode MIME quoted-printable data

  * "uu" --- Encode and decode uuencode files

* Structured Markup Processing Tools

  * "html" --- HyperText Markup Language support

  * "html.parser" --- Simple HTML and XHTML parser

  * "html.entities" --- Definitions of HTML general entities

  * XML 處理模組

  * "xml.etree.ElementTree" --- The ElementTree XML API

  * "xml.dom" --- The Document Object Model API

  * "xml.dom.minidom" --- Minimal DOM implementation

  * "xml.dom.pulldom" --- Support for building partial DOM trees

  * "xml.sax" --- Support for SAX2 parsers

  * "xml.sax.handler" --- Base classes for SAX handlers

  * "xml.sax.saxutils" --- SAX Utilities

  * "xml.sax.xmlreader" --- Interface for XML parsers

  * "xml.parsers.expat" --- Fast XML parsing using Expat

* Internet Protocols and Support

  * "webbrowser" --- Convenient Web-browser controller

  * "cgi" --- Common Gateway Interface support

  * "cgitb" --- Traceback manager for CGI scripts

  * "wsgiref" --- WSGI Utilities and Reference Implementation

  * "urllib" --- URL handling modules

  * "urllib.request" --- Extensible library for opening URLs

  * "urllib.response" --- Response classes used by urllib

  * "urllib.parse" --- Parse URLs into components

  * "urllib.error" --- Exception classes raised by urllib.request

  * "urllib.robotparser" ---  Parser for robots.txt

  * "http" --- HTTP modules

  * "http.client" --- HTTP protocol client

  * "ftplib" --- FTP protocol client

  * "poplib" --- POP3 protocol client

  * "imaplib" --- IMAP4 protocol client

  * "nntplib" --- NNTP protocol client

  * "smtplib" --- SMTP protocol client

  * "smtpd" --- SMTP Server

  * "telnetlib" --- Telnet client

  * "uuid" --- UUID objects according to **RFC 4122**

  * "socketserver" --- A framework for network servers

  * "http.server" --- HTTP servers

  * "http.cookies" --- HTTP state management

  * "http.cookiejar" --- Cookie handling for HTTP clients

  * "xmlrpc" --- XMLRPC server and client modules

  * "xmlrpc.client" --- XML-RPC client access

  * "xmlrpc.server" --- Basic XML-RPC servers

  * "ipaddress" --- IPv4/IPv6 manipulation library

* Multimedia Services

  * "audioop" --- Manipulate raw audio data

  * "aifc" --- Read and write AIFF and AIFC files

  * "sunau" --- Read and write Sun AU files

  * "wave" --- Read and write WAV files

  * "chunk" --- Read IFF chunked data

  * "colorsys" --- Conversions between color systems

  * "imghdr" --- Determine the type of an image

  * "sndhdr" --- Determine type of sound file

  * "ossaudiodev" --- Access to OSS-compatible audio devices

* 國際化

  * "gettext" --- Multilingual internationalization services

  * "locale" --- Internationalization services

* 程式框架

  * "turtle" --- 龜圖學

  * "cmd" --- Support for line-oriented command interpreters

  * "shlex" --- Simple lexical analysis

* 以 Tk 打造 GUI

  * "tkinter" --- Python interface to Tcl/Tk

  * "tkinter.ttk" --- Tk themed widgets

  * "tkinter.tix" --- Extension widgets for Tk

  * "tkinter.scrolledtext" --- Scrolled Text Widget

  * IDLE

  * 其它的 GUI

* 開發工具

  * "typing" --- Support for type hints

  * "pydoc" --- Documentation generator and online help system

  * "doctest" --- Test interactive Python examples

  * "unittest" --- 單元測試框架

  * "unittest.mock" --- mock object library

  * "unittest.mock" --- getting started

  * 2to3 - 自動將 Python 2的程式碼轉成 Python 3

  * "test" --- Regression tests package for Python

  * "test.support" --- Utilities for the Python test suite

  * "test.support.script_helper" --- Utilities for the Python
    execution tests

* Debugging and Profiling

  * Audit events table

  * "bdb" --- Debugger framework

  * "faulthandler" --- Dump the Python traceback

  * "pdb" --- The Python Debugger

  * The Python Profilers

  * "timeit" --- Measure execution time of small code snippets

  * "trace" --- Trace or track Python statement execution

  * "tracemalloc" --- Trace memory allocations

* 軟體封裝與發布

  * "distutils" --- Building and installing Python modules

  * "ensurepip" --- Bootstrapping the "pip" installer

  * "venv" --- Creation of virtual environments

  * "zipapp" --- Manage executable Python zip archives

* Python Runtime Services

  * "sys" --- System-specific parameters and functions

  * "sysconfig" --- Provide access to Python's configuration
    information

  * "builtins" --- Built-in objects

  * "__main__" --- Top-level script environment

  * "warnings" --- Warning control

  * "dataclasses" --- Data Classes

  * "contextlib" --- Utilities for "with"-statement contexts

  * "abc" --- Abstract Base Classes

  * "atexit" --- Exit handlers

  * "traceback" --- Print or retrieve a stack traceback

  * "__future__" --- Future statement definitions

  * "gc" --- Garbage Collector interface

  * "inspect" --- Inspect live objects

  * "site" --- Site-specific configuration hook

* Custom Python Interpreters

  * "code" --- Interpreter base classes

  * "codeop" --- Compile Python code

* 匯入模組

  * "zipimport" --- Import modules from Zip archives

  * "pkgutil" --- Package extension utility

  * "modulefinder" --- Find modules used by a script

  * "runpy" --- Locating and executing Python modules

  * "importlib" --- "import" 的实现

  * Using importlib.metadata

* Python Language Services

  * "parser" --- Access Python parse trees

  * "ast" --- Abstract Syntax Trees

  * "symtable" --- Access to the compiler's symbol tables

  * "symbol" --- Constants used with Python parse trees

  * "token" --- Constants used with Python parse trees

  * "keyword" --- Testing for Python keywords

  * "tokenize" --- Tokenizer for Python source

  * "tabnanny" --- Detection of ambiguous indentation

  * "pyclbr" --- Python class browser support

  * "py_compile" --- Compile Python source files

  * "compileall" --- Byte-compile Python libraries

  * "dis" --- Python bytecode的反組譯器

  * "pickletools" --- Tools for pickle developers

* Miscellaneous Services

  * "formatter" --- Generic output formatting

* MS Windows Specific Services

  * "msilib" --- Read and write Microsoft Installer files

  * "msvcrt" --- Useful routines from the MS VC++ runtime

  * "winreg" --- Windows registry access

  * "winsound" --- Sound-playing interface for Windows

* Unix Specific Services

  * "posix" --- The most common POSIX system calls

  * "pwd" --- The password database

  * "spwd" --- The shadow password database

  * "grp" --- The group database

  * "crypt" --- Function to check Unix passwords

  * "termios" --- POSIX style tty control

  * "tty" --- Terminal control functions

  * "pty" --- Pseudo-terminal utilities

  * "fcntl" --- The "fcntl" and "ioctl" system calls

  * "pipes" --- Interface to shell pipelines

  * "resource" --- Resource usage information

  * "nis" --- Interface to Sun's NIS (Yellow Pages)

  * "syslog" --- Unix syslog library routines

* Superseded Modules

  * "optparse" --- Parser for command line options

  * "imp" --- Access the *import* internals

* Undocumented Modules

  * Platform specific modules
