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.
and
, or
, not
int
, float
, long
, complex
str
, unicode
, list
, tuple
, bytearray
, buffer
, xrange
set
, frozenset
dict
string
— Common string operationsre
— Regular expression operationsstruct
— Interpret strings as packed binary datadifflib
— Helpers for computing deltasStringIO
— Read and write strings as filescStringIO
— Faster version of StringIO
textwrap
— Text wrapping and fillingcodecs
— Codec registry and base classesunicodedata
— Unicode Databasestringprep
— Internet String Preparationfpformat
— Floating point conversionsdatetime
— Basic date and time typescalendar
— General calendar-related functionscollections
— High-performance container datatypesheapq
— Heap queue algorithmbisect
— Array bisection algorithmarray
— Efficient arrays of numeric valuessets
— Unordered collections of unique elementssched
— Event schedulermutex
— Mutual exclusion supportQueue
— A synchronized queue classweakref
— Weak referencesUserDict
— Class wrapper for dictionary objectsUserList
— Class wrapper for list objectsUserString
— Class wrapper for string objectstypes
— Names for built-in typesnew
— Creation of runtime internal objectscopy
— Shallow and deep copy operationspprint
— Data pretty printerrepr
— Alternate repr()
implementationnumbers
— Numeric abstract base classesmath
— Mathematical functionscmath
— 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 functionsos.path
— Common pathname manipulationsfileinput
— Iterate over lines from multiple input streamsstat
— Interpreting stat()
resultsstatvfs
— Constants used with os.statvfs()
filecmp
— 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 operationsdircache
— Cached directory listingsmacpath
— Mac OS 9 path manipulation functionspickle
— Python object serializationcPickle
— A faster pickle
copy_reg
— Register pickle
support functionsshelve
— Python object persistencemarshal
— Internal Python object serializationanydbm
— Generic access to DBM-style databaseswhichdb
— Guess which DBM module created a databasedbm
— Simple “database” interfacegdbm
— GNU’s reinterpretation of dbmdbhash
— DBM-style interface to the BSD database librarybsddb
— Interface to Berkeley DB librarydumbdbm
— Portable DBM implementationsqlite3
— DB-API 2.0 interface for SQLite databasesos
— Miscellaneous operating system interfacesio
— Core tools for working with streamstime
— Time access and conversionsargparse
— Parser for command-line options, arguments and sub-commandsoptparse
— Parser for command line optionsgetopt
— C-style parser for command line optionslogging
— Logging facility for Pythonlogging.config
— Logging configurationlogging.handlers
— Logging handlersgetpass
— Portable password inputcurses
— Terminal handling for character-cell displayscurses.textpad
— Text input widget for curses programscurses.ascii
— Utilities for ASCII characterscurses.panel
— A panel stack extension for cursesplatform
— Access to underlying platform’s identifying dataerrno
— Standard errno system symbolsctypes
— A foreign function library for Pythonselect
— Waiting for I/O completionthreading
— Higher-level threading interfacethread
— Multiple threads of controldummy_threading
— Drop-in replacement for the threading
moduledummy_thread
— Drop-in replacement for the thread
modulemultiprocessing
— Process-based “threading” interfacemmap
— Memory-mapped file supportreadline
— GNU readline interfacerlcompleter
— Completion function for GNU readlinesubprocess
— Subprocess managementsocket
— Low-level networking interfacessl
— TLS/SSL wrapper for socket objectssignal
— Set handlers for asynchronous eventspopen2
— Subprocesses with accessible I/O streamsasyncore
— Asynchronous socket handlerasynchat
— Asynchronous socket command/response handleremail
— An email and MIME handling packagejson
— JSON encoder and decodermailcap
— Mailcap file handlingmailbox
— Manipulate mailboxes in various formatsmhlib
— Access to MH mailboxesmimetools
— Tools for parsing MIME messagesmimetypes
— Map filenames to MIME typesMimeWriter
— Generic MIME file writermimify
— MIME processing of mail messagesmultifile
— Support for files containing distinct partsrfc822
— Parse RFC 2822 mail headersbase64
— 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 filesHTMLParser
— Simple HTML and XHTML parsersgmllib
— Simple SGML parserhtmllib
— A parser for HTML documentshtmlentitydefs
— Definitions of HTML general entitiesxml.etree.ElementTree
— The ElementTree XML APIxml.dom
— The Document Object Model APIxml.dom.minidom
— Minimal 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.parsers.expat
— Fast XML parsing using Expatwebbrowser
— Convenient Web-browser controllercgi
— Common Gateway Interface supportcgitb
— Traceback manager for CGI scriptswsgiref
— WSGI Utilities and Reference Implementationurllib
— Open arbitrary resources by URLurllib2
— extensible library for opening URLshttplib
— 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 4122urlparse
— Parse URLs into componentsSocketServer
— A framework for network serversBaseHTTPServer
— Basic HTTP serverSimpleHTTPServer
— Simple HTTP request handlerCGIHTTPServer
— CGI-capable HTTP request handlercookielib
— Cookie handling for HTTP clientsCookie
— HTTP state managementxmlrpclib
— XML-RPC client accessSimpleXMLRPCServer
— Basic XML-RPC serverDocXMLRPCServer
— Self-documenting XML-RPC serveraudioop
— Manipulate raw audio dataimageop
— Manipulate raw image 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 devicespydoc
— Documentation generator and online help systemdoctest
— Test interactive Python examplesunittest
— Unit testing frameworktest
— Regression tests package for Pythontest.support
— Utility functions for testssys
— System-specific parameters and functionssysconfig
— Provide access to Python’s configuration information__builtin__
— Built-in objectsfuture_builtins
— Python 3 builtins__main__
— Top-level script environmentwarnings
— Warning controlcontextlib
— Utilities for with
-statement contextsabc
— Abstract Base Classesatexit
— Exit handlerstraceback
— Print or retrieve a stack traceback__future__
— Future statement definitionsgc
— Garbage Collector interfaceinspect
— Inspect live objectssite
— Site-specific configuration hookuser
— User-specific configuration hookfpectl
— Floating point exception controlimp
— Access the import
internalsimportlib
— Convenience wrappers for __import__()
imputil
— Import utilitieszipimport
— Import modules from Zip archivespkgutil
— Package extension utilitymodulefinder
— Find modules used by a scriptrunpy
— Locating and executing Python modulesparser
— Access Python parse treesast
— Abstract Syntax Treessymtable
— 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 developersposix
— The most common POSIX system callspwd
— The password databasespwd
— The shadow password databasegrp
— The group databasecrypt
— Function to check Unix passwordsdl
— Call C functions in shared objectstermios
— POSIX style tty controltty
— Terminal control functionspty
— Pseudo-terminal utilitiesfcntl
— The fcntl
and ioctl
system callspipes
— Interface to shell pipelinesposixfile
— File-like objects with locking supportresource
— Resource usage informationnis
— Interface to Sun’s NIS (Yellow Pages)syslog
— Unix syslog library routinescommands
— Utilities for running commandsic
— Access to the Mac OS X Internet ConfigMacOS
— Access to Mac OS interpreter featuresmacostools
— Convenience routines for file manipulationfindertools
— The finder’s Apple Events interfaceEasyDialogs
— Basic Macintosh dialogsFrameWork
— Interactive application frameworkautoGIL
— Global Interpreter Lock handling in event loopsColorPicker
— Color selection dialogal
— Audio functions on the SGIAL
— Constants used with the al
modulecd
— CD-ROM access on SGI systemsfl
— FORMS library for graphical user interfacesFL
— Constants used with the fl
moduleflp
— Functions for loading stored FORMS designsfm
— Font Manager interfacegl
— Graphics Library interfaceDEVICE
— Constants used with the gl
moduleGL
— Constants used with the gl
moduleimgfile
— Support for SGI imglib filesjpeg
— Read and write JPEG files
© 2001–2020 Python Software Foundation
Licensed under the PSF License.
https://docs.python.org/2.7/library/index.html