Python Documentation contents¶
- What’s New in Python
- What’s New In Python 3.0
- What’s New in Python 2.7
- What’s New in Python 2.6
- Python 3.0
- Changes to the Development Process
- PEP 343: The 『with』 statement
- PEP 366: Explicit Relative Imports From a Main Module
- PEP 370: Per-user
site-packagesDirectory - PEP 371: The
multiprocessingPackage - PEP 3101: Advanced String Formatting
- PEP 3105:
printAs a Function - PEP 3110: Exception-Handling Changes
- PEP 3112: Byte Literals
- PEP 3116: New I/O Library
- PEP 3118: Revised Buffer Protocol
- PEP 3119: Abstract Base Classes
- PEP 3127: Integer Literal Support and Syntax
- PEP 3129: Class Decorators
- PEP 3141: A Type Hierarchy for Numbers
- Other Language Changes
- New, Improved, and Deprecated Modules
- Build and C API Changes
- Porting to Python 2.6
- Acknowledgements
- What’s New in Python 2.5
- PEP 308: Conditional Expressions
- PEP 309: Partial Function Application
- PEP 314: Metadata for Python Software Packages v1.1
- PEP 328: Absolute and Relative Imports
- PEP 338: Executing Modules as Scripts
- PEP 341: Unified try/except/finally
- PEP 342: New Generator Features
- PEP 343: The 『with』 statement
- PEP 352: Exceptions as New-Style Classes
- PEP 353: Using ssize_t as the index type
- PEP 357: The 『__index__』 method
- Other Language Changes
- New, Improved, and Removed Modules
- Build and C API Changes
- Porting to Python 2.5
- Acknowledgements
- What’s New in Python 2.4
- PEP 218: Built-In Set Objects
- PEP 237: Unifying Long Integers and Integers
- PEP 289: Generator Expressions
- PEP 292: Simpler String Substitutions
- PEP 318: Decorators for Functions and Methods
- PEP 322: Reverse Iteration
- PEP 324: New subprocess Module
- PEP 327: Decimal Data Type
- PEP 328: Multi-line Imports
- PEP 331: Locale-Independent Float/String Conversions
- Other Language Changes
- New, Improved, and Deprecated Modules
- Build and C API Changes
- Porting to Python 2.4
- Acknowledgements
- What’s New in Python 2.3
- PEP 218: A Standard Set Datatype
- PEP 255: Simple Generators
- PEP 263: Source Code Encodings
- PEP 273: Importing Modules from ZIP Archives
- PEP 277: Unicode file name support for Windows NT
- PEP 278: Universal Newline Support
- PEP 279: enumerate()
- PEP 282: The logging Package
- PEP 285: A Boolean Type
- PEP 293: Codec Error Handling Callbacks
- PEP 301: Package Index and Metadata for Distutils
- PEP 302: New Import Hooks
- PEP 305: Comma-separated Files
- PEP 307: Pickle Enhancements
- Extended Slices
- Other Language Changes
- New, Improved, and Deprecated Modules
- Pymalloc: A Specialized Object Allocator
- Build and C API Changes
- Other Changes and Fixes
- Porting to Python 2.3
- Acknowledgements
- What’s New in Python 2.2
- Introduction
- PEPs 252 and 253: Type and Class Changes
- PEP 234: Iterators
- PEP 255: Simple Generators
- PEP 237: Unifying Long Integers and Integers
- PEP 238: Changing the Division Operator
- Unicode Changes
- PEP 227: Nested Scopes
- New and Improved Modules
- Interpreter Changes and Fixes
- Other Changes and Fixes
- Acknowledgements
- What’s New in Python 2.1
- Introduction
- PEP 227: Nested Scopes
- PEP 236: __future__ Directives
- PEP 207: Rich Comparisons
- PEP 230: Warning Framework
- PEP 229: New Build System
- PEP 205: Weak References
- PEP 232: Function Attributes
- PEP 235: Importing Modules on Case-Insensitive Platforms
- PEP 217: Interactive Display Hook
- PEP 208: New Coercion Model
- PEP 241: Metadata in Python Packages
- New and Improved Modules
- Other Changes and Fixes
- Acknowledgements
- What’s New in Python 2.0
- Introduction
- What About Python 1.6?
- New Development Process
- Unicode
- List Comprehensions
- Augmented Assignment
- String Methods
- Garbage Collection of Cycles
- Other Core Changes
- Porting to 2.0
- Extending/Embedding Changes
- Distutils: Making Modules Easy to Install
- XML Modules
- Module changes
- New modules
- IDLE Improvements
- Deleted and Deprecated Modules
- Acknowledgements
- Python 教學
- Whetting Your Appetite
- Using the Python Interpreter
- An Informal Introduction to Python
- More Control Flow Tools
- Data Structures
- Modules
- 輸入和輸出
- 錯誤與例外
- 類別
- Brief Tour of the Standard Library
- Brief Tour of the Standard Library – Part II
- What Now?
- Interactive Input Editing and History Substitution
- Floating Point Arithmetic: Issues and Limitations
- Using Python
- The Python Language Reference
- Introduction
- Lexical analysis
- Data model
- Execution model
- Expressions
- Simple statements
- Compound statements
- Top-level components
- Full Grammar specification
- The Python Standard Library
- Introduction
- Built-in Functions
- Built-in Constants
- Built-in Objects
- Built-in Types
- Truth Value Testing
- Boolean Operations —
and,or,not - Comparisons
- Numeric Types —
int,float,complex - Iterator Types
- Sequence Types —
str,bytes,bytearray,list,tuple,range - Set Types —
set,frozenset - Mapping Types —
dict - File Objects
- memoryview Types
- Context Manager Types
- Other Built-in Types
- Special Attributes
- Built-in Exceptions
- String Services
string— Common string operationsre— Regular expression operationsstruct— Interpret bytes as packed binary datadifflib— Helpers for computing deltastextwrap— Text wrapping and fillingcodecs— Codec registry and base classesunicodedata— Unicode Databasestringprep— Internet String Preparation
- Data Types
datetime— Basic date and time typescalendar— General calendar-related functionscollections— Container datatypesheapq— Heap queue algorithmbisect— Array bisection algorithmarray— Efficient arrays of numeric valuessched— Event schedulerqueue— A synchronized queue classweakref— Weak referencestypes— Names for built-in typescopy— Shallow and deep copy operationspprint— Data pretty printerreprlib— Alternaterepr()implementation
- Numeric and Mathematical Modules
numbers— Numeric abstract base classesmath— Mathematical functions- Constants
cmath— Mathematical functions for complex numbersdecimal— Decimal fixed point and floating point arithmeticfractions— Rational numbersrandom— Generate pseudo-random numbersitertools— Functions creating iterators for efficient loopingfunctools— Higher order functions and operations on callable objectsoperator— Standard operators as functions
- File and Directory Access
os.path— Common pathname manipulationsfileinput— Iterate over lines from multiple input streamsstat— Interpretingstat()resultsfilecmp— File and Directory Comparisonstempfile— Generate temporary files and directoriesglob— Unix style pathname pattern expansionfnmatch— Unix filename pattern matchinglinecache— Random access to text linesshutil— High-level file operationsmacpath— Mac OS 9 path manipulation functions
- Data Persistence
pickle— Python object serializationcopyreg— Registerpicklesupport functionsshelve— Python object persistencemarshal— Internal Python object serializationdbm— Interfaces to Unix 「databases」sqlite3— DB-API 2.0 interface for SQLite databases
- Data Compression and Archiving
- File Formats
- Cryptographic Services
- Generic Operating System Services
os— Miscellaneous operating system interfacesio— Core tools for working with streamstime— Time access and conversionsoptparse— More powerful command line option parser- Background
- Tutorial
- Reference Guide
- Option Callbacks
- Defining a callback option
- How callbacks are called
- Raising errors in a callback
- Callback example 1: trivial callback
- Callback example 2: check option order
- Callback example 3: check option order (generalized)
- Callback example 4: check arbitrary condition
- Callback example 5: fixed arguments
- Callback example 6: variable arguments
- Extending
optparse
getopt— Parser for command line optionslogging— Logging facility for Python- Logging tutorial
- Logging Levels
- Useful Handlers
- Module-Level Functions
- Logger Objects
- Basic example
- Logging to multiple destinations
- Adding contextual information to your logging output
- Sending and receiving logging events across a network
- Handler Objects
- Formatter Objects
- Filter Objects
- LogRecord Objects
- LoggerAdapter Objects
- Thread Safety
- Configuration
- More examples
getpass— Portable password inputcurses— Terminal handling for character-cell displayscurses.textpad— Text input widget for curses programscurses.wrapper— Terminal handler for curses programscurses.ascii— Utilities for ASCII characterscurses.panel— A panel stack extension for curses.platform— Access to underlying platform’s identifying data.errno— Standard errno system symbolsctypes— A foreign function library for Python.- ctypes tutorial
- Loading dynamic link libraries
- Accessing functions from loaded dlls
- Calling functions
- Fundamental data types
- Calling functions, continued
- Calling functions with your own custom data types
- Specifying the required argument types (function prototypes)
- Return types
- Passing pointers (or: passing parameters by reference)
- Structures and unions
- Structure/union alignment and byte order
- Bit fields in structures and unions
- Arrays
- Pointers
- Type conversions
- Incomplete Types
- Callback functions
- Accessing values exported from dlls
- Surprises
- Variable-sized data types
- ctypes reference
- ctypes tutorial
- Optional Operating System Services
select— Waiting for I/O completionthreading— Higher-level threading interfacedummy_threading— Drop-in replacement for thethreadingmodule_thread— Low-level threading API_dummy_thread— Drop-in replacement for the_threadmodulemultiprocessing— Process-based 「threading」 interfacemmap— Memory-mapped file supportreadline— GNU readline interfacerlcompleter— Completion function for GNU readline
- Interprocess Communication and Networking
- Internet Data Handling
email— An email and MIME handling packageemail: Representing an email messageemail: Parsing email messagesemail: Generating MIME documentsemail: Creating email and MIME objects from scratchemail: Internationalized headersemail: Representing character setsemail: Encodersemail: Exception and Defect classesemail: Miscellaneous utilitiesemail: Iteratorsemail: Examples- Package History
- Differences from
mimelib
json— JSON encoder and decodermailcap— Mailcap file handlingmailbox— Manipulate mailboxes in various formatsmimetypes— Map filenames to MIME typesbase64— RFC 3548: Base16, Base32, Base64 Data Encodingsbinhex— Encode and decode binhex4 filesbinascii— Convert between binary and ASCIIquopri— Encode and decode MIME quoted-printable datauu— Encode and decode uuencode files
- Structured Markup Processing Tools
html.parser— Simple HTML and XHTML parserhtml.entities— Definitions of HTML general entitiesxml.parsers.expat— Fast XML parsing using Expatxml.dom— The Document Object Model APIxml.dom.minidom— Lightweight DOM implementationxml.dom.pulldom— Support for building partial DOM treesxml.sax— Support for SAX2 parsersxml.sax.handler— Base classes for SAX handlersxml.sax.saxutils— SAX Utilitiesxml.sax.xmlreader— Interface for XML parsersxml.etree.ElementTree— The ElementTree XML API
- Internet Protocols and Support
webbrowser— Convenient Web-browser controllercgi— Common Gateway Interface support.cgitb— Traceback manager for CGI scriptswsgiref— WSGI Utilities and Reference Implementationurllib.request— extensible library for opening URLs- Request Objects
- OpenerDirector Objects
- BaseHandler Objects
- HTTPRedirectHandler Objects
- HTTPCookieProcessor Objects
- ProxyHandler Objects
- HTTPPasswordMgr Objects
- AbstractBasicAuthHandler Objects
- HTTPBasicAuthHandler Objects
- ProxyBasicAuthHandler Objects
- AbstractDigestAuthHandler Objects
- HTTPDigestAuthHandler Objects
- ProxyDigestAuthHandler Objects
- HTTPHandler Objects
- HTTPSHandler Objects
- FileHandler Objects
- FTPHandler Objects
- CacheFTPHandler Objects
- UnknownHandler Objects
- HTTPErrorProcessor Objects
- 範例
urllib.requestRestrictions
urllib.response— Response classes used by urllib.urllib.parse— Parse URLs into componentsurllib.error— Exception classes raised by urllib.requesturllib.robotparser— Parser for robots.txthttp.client— HTTP protocol clientftplib— FTP protocol clientpoplib— POP3 protocol clientimaplib— IMAP4 protocol clientnntplib— NNTP protocol clientsmtplib— SMTP protocol clientsmtpd— SMTP Servertelnetlib— Telnet clientuuid— UUID objects according to RFC 4122socketserver— A framework for network servershttp.server— HTTP servershttp.cookies— HTTP state managementhttp.cookiejar— Cookie handling for HTTP clientsxmlrpc.client— XML-RPC client accessxmlrpc.server— Basic XML-RPC servers
- Multimedia Services
audioop— Manipulate raw audio dataaifc— Read and write AIFF and AIFC filessunau— Read and write Sun AU fileswave— Read and write WAV fileschunk— Read IFF chunked datacolorsys— Conversions between color systemsimghdr— Determine the type of an imagesndhdr— Determine type of sound fileossaudiodev— Access to OSS-compatible audio devices
- Internationalization
- Program Frameworks
- Graphical User Interfaces with Tk
tkinter— Python interface to Tcl/Tktkinter.tix— Extension widgets for Tktkinter.scrolledtext— Scrolled Text Widgetturtle— Turtle graphics for Tk- IDLE
- Other Graphical User Interface Packages
- Development Tools
pydoc— Documentation generator and online help systemdoctest— Test interactive Python examplesunittest— Unit testing framework- 2to3 - Automated Python 2 to 3 code translation
test— Regression tests package for Pythontest.support— Utility functions for tests
- Debugging and Profiling
- Python Runtime Services
sys— System-specific parameters and functionsbuiltins— Built-in objects__main__— Top-level script environmentwarnings— Warning controlcontextlib— Utilities forwith-statement contexts.abc— Abstract Base Classesatexit— Exit handlerstraceback— Print or retrieve a stack traceback__future__— Future statement definitionsgc— Garbage Collector interfaceinspect— Inspect live objectssite— Site-specific configuration hookfpectl— Floating point exception control
- Custom Python Interpreters
- Importing Modules
- Python Language Services
parser— Access Python parse trees- Abstract Syntax Trees
symtable— Access to the compiler’s symbol tablessymbol— Constants used with Python parse treestoken— Constants used with Python parse treeskeyword— Testing for Python keywordstokenize— Tokenizer for Python sourcetabnanny— Detection of ambiguous indentationpyclbr— Python class browser supportpy_compile— Compile Python source filescompileall— Byte-compile Python librariesdis— Disassembler for Python bytecodepickletools— Tools for pickle developers.distutils— Building and installing Python modules
- Miscellaneous Services
- MS Windows Specific Services
- Unix Specific Services
posix— The most common POSIX system callspwd— The password databasespwd— The shadow password databasegrp— The group databasecrypt— Function to check Unix passwordstermios— POSIX style tty controltty— Terminal control functionspty— Pseudo-terminal utilitiesfcntl— Thefcntl()andioctl()system callspipes— Interface to shell pipelinesresource— Resource usage informationnis— Interface to Sun’s NIS (Yellow Pages)syslog— Unix syslog library routines
- Undocumented Modules
- Extending and Embedding the Python Interpreter
- Extending Python with C or C++
- A Simple Example
- Intermezzo: Errors and Exceptions
- Back to the Example
- The Module’s Method Table and Initialization Function
- Compilation and Linkage
- Calling Python Functions from C
- Extracting Parameters in Extension Functions
- Keyword Parameters for Extension Functions
- Building Arbitrary Values
- Reference Counts
- Writing Extensions in C++
- Providing a C API for an Extension Module
- Defining New Types
- Building C and C++ Extensions with distutils
- Building C and C++ Extensions on Windows
- 將 Python 嵌入到另一個應用程式中
- Extending Python with C or C++
- Python/C API Reference Manual
- Introduction
- The Very High Level Layer
- Reference Counting
- Exception Handling
- Utilities
- Abstract Objects Layer
- Concrete Objects Layer
- Initialization, Finalization, and Threads
- Memory Management
- Object Implementation Support
- 散布 Python 模組
- An Introduction to Distutils
- Writing the Setup Script
- Writing the Setup Configuration File
- Creating a Source Distribution
- Creating Built Distributions
- Registering with the Package Index
- Uploading Packages to the Package Index
- 範例
- Extending Distutils
- Command Reference
- API Reference
distutils.core— Core Distutils functionalitydistutils.ccompiler— CCompiler base classdistutils.unixccompiler— Unix C Compilerdistutils.msvccompiler— Microsoft Compilerdistutils.bcppcompiler— Borland Compilerdistutils.cygwincompiler— Cygwin Compilerdistutils.emxccompiler— OS/2 EMX Compilerdistutils.mwerkscompiler— Metrowerks CodeWarrior supportdistutils.archive_util— Archiving utilitiesdistutils.dep_util— Dependency checkingdistutils.dir_util— Directory tree operationsdistutils.file_util— Single file operationsdistutils.util— Miscellaneous other utility functionsdistutils.dist— The Distribution classdistutils.extension— The Extension classdistutils.debug— Distutils debug modedistutils.errors— Distutils exceptionsdistutils.fancy_getopt— Wrapper around the standard getopt moduledistutils.filelist— The FileList classdistutils.log— Simple PEP 282-style loggingdistutils.spawn— Spawn a sub-processdistutils.sysconfig— System configuration informationdistutils.text_file— The TextFile classdistutils.version— Version number classesdistutils.cmd— Abstract base class for Distutils commandsdistutils.command— Individual Distutils commandsdistutils.command.bdist— Build a binary installerdistutils.command.bdist_packager— Abstract base class for packagersdistutils.command.bdist_dumb— Build a 「dumb」 installerdistutils.command.bdist_msi— Build a Microsoft Installer binary packagedistutils.command.bdist_rpm— Build a binary distribution as a Redhat RPM and SRPMdistutils.command.bdist_wininst— Build a Windows installerdistutils.command.sdist— Build a source distributiondistutils.command.build— Build all files of a packagedistutils.command.build_clib— Build any C libraries in a packagedistutils.command.build_ext— Build any extensions in a packagedistutils.command.build_py— Build the .py/.pyc files of a packagedistutils.command.build_scripts— Build the scripts of a packagedistutils.command.clean— Clean a package build areadistutils.command.config— Perform package configurationdistutils.command.install— Install a packagedistutils.command.install_data— Install data files from a packagedistutils.command.install_headers— Install C/C++ header files from a packagedistutils.command.install_lib— Install library files from a packagedistutils.command.install_scripts— Install script files from a packagedistutils.command.register— Register a module with the Python Package Index- Creating a new Distutils command
- 安裝 Python 模組
- Documenting Python
- Python HOWTOs
- Python Advocacy HOWTO
- Porting Extension Modules to 3.0
- Curses Programming with Python
- Idioms and Anti-Idioms in Python
- Functional Programming HOWTO
- Regular Expression HOWTO
- Socket Programming HOWTO
- Unicode HOWTO
- HOWTO Fetch Internet Resources Using The urllib Package
- HOWTO Use Python in the web
- Glossary
- About these documents
- Reporting Bugs in Python
- 著作權
- 歷史與授權
