Die Python-Standardbibliothek¶
Dieses Referenzhandbuch der Bibliothek beschreibt die Standardbibliothek, die mit Python ausgeliefert wird. Es beschreibt außerdem einige der optionalen Bestandteile, die üblicherweise in Python-Distributionen enthalten sind.
An anderer Stelle beschreibt Die Python-Sprachreferenz die genaue Syntax und Semantik der Sprache Python, und Referenz der integrierten Python-Objekte beschreibt die integrierten Funktionen.
Pythons Standardbibliothek ist umfangreich und bietet ein breites Spektrum an Möglichkeiten, wie das lange Inhaltsverzeichnis weiter unten zeigt. Die Bibliothek enthält integrierte Module, die in C geschrieben sind und Zugriff auf Systemfunktionen wie Datei-E/A bieten, der Python-Programmierern sonst verwehrt bliebe, sowie Module in Python, die standardisierte Lösungen für viele Probleme des täglichen Programmierens bereitstellen. Einige dieser Module sind ausdrücklich darauf ausgelegt, die Portabilität von Python-Programmen zu fördern und zu verbessern, indem sie Besonderheiten der Plattform hinter plattformneutralen APIs verbergen.
Die Python-Installationsprogramme für die Windows-Plattform enthalten in der Regel die gesamte Standardbibliothek und oft auch viele zusätzliche Bestandteile. Auf unixartigen Betriebssystemen wird Python normalerweise als Sammlung von Paketen bereitgestellt. Dort kann es nötig sein, die Paketwerkzeuge des Betriebssystems zu verwenden, um einige oder alle optionalen Bestandteile zu erhalten.
Neben der Standardbibliothek gibt es eine lebendige Sammlung von Hunderttausenden Bestandteilen – von einzelnen Programmen und Modulen bis zu Paketen und ganzen Frameworks für die Anwendungsentwicklung –, die über den Python Package Index zu beziehen sind.
- Einführung
- Dienste zur Textverarbeitung
string— Allgemeine Zeichenkettenoperationenstring.templatelib— Unterstützung für Template-String-Literalere— Operationen mit regulären Ausdrückendifflib— Helpers for computing deltastextwrap— Text wrapping and fillingunicodedata— Unicode Databasestringprep— Internet String Preparationreadline— GNU readline interfacerlcompleter— Vervollständigungsfunktion für GNU readline
- Binary Data Services
- Datentypen
datetime— Basic date and time typeszoneinfo— IANA time zone supportcalendar— Allgemeine kalenderbezogene Funktionencollections— Container-Datentypencollections.abc— Abstract Base Classes for Containersheapq— Heap queue algorithmbisect— Array bisection algorithmarray— Platzsparende Arrays numerischer Werteweakref— Weak referencestypes— Dynamische Typerzeugung und Namen für integrierte Typencopy— Flache und tiefe Kopieroperationenpprint— Datenstrukturen ansprechend ausgebenreprlib— Alternaterepr()implementationenum— Support for enumerationsgraphlib— Functionality to operate with graph-like structures
- Numerische und mathematische Module
numbers— Abstrakte Basisklassen für Zahlenmath— Mathematical functionsmath.integer— mathematische Funktionen speziell für ganze Zahlencmath— Mathematische Funktionen für komplexe Zahlendecimal— Dezimale Festkomma- und Gleitkommaarithmetikfractions— Rational numbersrandom— Generate pseudo-random numbersstatistics— Mathematical statistics functions
- Module zur funktionalen Programmierung
- File and Directory Access
pathlib— Object-oriented filesystem pathsos.path— Common pathname manipulationsstat— Interpretingstat()resultsfilecmp— File and Directory Comparisonstempfile— Generate temporary files and directoriesglob— Pfadnamensexpansion nach Unix-Artfnmatch— Mustervergleich für Unix-Dateinamenlinecache— Zufälliger Zugriff auf Textzeilenshutil— High-level file operations
- Datenpersistenz
- Data Compression and Archiving
- The
compressionpackage compression.zstd— Compression compatible with the Zstandard formatzlib— Compression compatible with gzipgzip— Support for gzip filesbz2— Support for bzip2 compressionlzma— Compression using the LZMA algorithmzipfile— Mit ZIP-Archiven arbeitentarfile— Read and write tar archive files
- The
- File Formats
- Cryptographic Services
- Generic Operating System Services
os— Verschiedene Betriebssystemschnittstellenio— Core tools for working with streamstime— Zeitzugriff und Zeitumrechnungenlogging— Logging facility for Pythonlogging.config— Logging configurationlogging.handlers— Logging handlersplatform— Access to underlying platform’s identifying dataerrno— Standard errno system symbolsctypes— Eine Fremdfunktionsbibliothek für Python
- Command-line interface libraries
argparse— Parser für Befehlszeilenoptionen, -argumente und Unterbefehleoptparse— Parser for command line optionsgetpass— Portable password inputfileinput— Iterate over lines from multiple input streamscurses— Terminal handling for character-cell displayscurses.textpad— Text input widget for curses programscurses.ascii— Utilities for ASCII characterscurses.panel— Eine Panel-Stapel-Erweiterung für cursescmd— Unterstützung für zeilenorientierte Befehlsinterpreter
- Concurrent Execution
threading— Thread-based parallelismmultiprocessing— Process-based parallelismmultiprocessing.shared_memory— Shared memory for direct access across processes- The
concurrentpackage concurrent.futures— Launching parallel tasksconcurrent.interpreters— Multiple interpreters in the same processsubprocess— Subprocess managementsched— Ereignis-Schedulerqueue— A synchronized queue classcontextvars— Context Variables_thread— Low-level threading API
- Networking and Interprocess Communication
- Verarbeitung von Internetdaten
email— An email and MIME handling packagejson— JSON-Kodierer und -Dekodierermailbox— Manipulate mailboxes in various formatsmimetypes— Map filenames to MIME typesbase64— Base16, Base32, Base64, Base85 Data Encodingsbinascii— Convert between binary and ASCIIquopri— Encode and decode MIME quoted-printable data
- Werkzeuge zur Verarbeitung strukturierter Auszeichnungssprachen
html— HyperText Markup Language supporthtml.parser— Simple HTML and XHTML parserhtml.entities— Definitionen allgemeiner HTML-Entitäten- XML Processing Modules
xml.etree.ElementTree— The ElementTree XML APIxml.dom— Die API des Document Object Modelxml.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 Expat
- Internetprotokolle und Unterstützung dafür
webbrowser— Bequeme Steuerung von Webbrowsernwsgiref— WSGI-Hilfsmittel und Referenzimplementierungurllib— URL handling modulesurllib.request— Extensible library for opening URLsurllib.response— Response classes used by urlliburllib.parse— Parse URLs into componentsurllib.error— Exception classes raised by urllib.requesturllib.robotparser— Parser for robots.txthttp— HTTP moduleshttp.client— HTTP protocol clientftplib— FTP protocol clientpoplib— POP3 protocol clientimaplib— IMAP4 protocol clientsmtplib— SMTP protocol clientuuid— UUID objects according to RFC 9562socketserver— A framework for network servershttp.server— HTTP servershttp.cookies— HTTP state managementhttp.cookiejar— Cookie handling for HTTP clientsxmlrpc— XMLRPC server and client modulesxmlrpc.client— XML-RPC client accessxmlrpc.server— Basic XML-RPC serversipaddress— Bibliothek zum Umgang mit IPv4 und IPv6
- Multimedia-Dienste
- Internationalization
- Grafische Benutzeroberflächen mit Tk
tkinter— Python-Schnittstelle zu Tcl/Tktkinter.colorchooser— Dialog zur Farbauswahltkinter.font— Tkinter-Hülle für Schriftarten- Tkinter-Dialoge
tkinter.messagebox— Meldungsdialoge von Tkintertkinter.scrolledtext— Text-Widget mit Scrollbartkinter.dnd— Unterstützung für Drag-and-droptkinter.ttk— Tk-Widgets mit Themes- IDLE — Python editor and shell
turtle— Turtle-Grafik
- Development Tools
typing— Unterstützung für Typhinweisepydoc— Dokumentationserzeuger und Online-Hilfesystem- Python Development Mode
doctest— Test interactive Python examplesunittest— Unit testing frameworkunittest.mock— mock object libraryunittest.mock— getting startedtest— Paket mit den Regressionstests für Pythontest.support— Werkzeuge für die Python-Testsuitetest.support.socket_helper— Werkzeuge für Socket-Teststest.support.script_helper— Werkzeuge für die Tests der Python-Ausführungtest.support.bytecode_helper— Hilfswerkzeuge, um die korrekte Bytecode-Erzeugung zu prüfentest.support.threading_helper— Werkzeuge für Threading-Teststest.support.os_helper— Werkzeuge für os-Teststest.support.import_helper— Werkzeuge für Import-Teststest.support.warnings_helper— Werkzeuge für Warnungs-Tests
- Debugging and profiling
- Audit events table
bdb— Debugger frameworkfaulthandler— Dump the Python tracebackpdb— The Python Debuggerprofiling— Python profilerspstats— Statistics for profilerstimeit— Measure execution time of small code snippetstrace— Trace or track Python statement executiontracemalloc— Speicherreservierungen aufzeichnen
- Software Packaging and Distribution
- Dienste der Python-Laufzeitumgebung
sys— System-specific parameters and functionssys.monitoring— Execution event monitoringsysconfig— Provide access to Python’s configuration informationbuiltins— Built-in objects__main__— Top-Level-Codeumgebungwarnings— Warnungen steuerndataclasses— Data Classescontextlib— Utilities forwith-statement contextsabc— Abstrakte Basisklassenatexit— Exit handlerstraceback— Print or retrieve a stack traceback__future__— Definitionen von Future-Anweisungengc— Garbage Collector interfaceinspect— Inspect live objectsannotationlib— Functionality for introspecting annotationssite— Einhängepunkt für installationsspezifische Konfiguration
- Custom Python Interpreters
- Module importieren
zipimport— Import modules from Zip archivespkgutil— Package extension utilitymodulefinder— Von einem Skript verwendete Module findenrunpy— Locating and executing Python modulesimportlib— The implementation ofimportimportlib.resources– Package resource reading, opening and accessimportlib.resources.abc– Abstract base classes for resourcesimportlib.metadata– Accessing package metadata- The initialization of the
sys.pathmodule search path
- Dienste für die Python-Sprache
ast— Abstract syntax treessymtable— Access to the compiler’s symbol tablestoken— Konstanten für Python-Parsebäumekeyword— Auf Python-Schlüsselwörter prüfentokenize— Tokenizer für Python-Quellcodetabnanny— Detection of ambiguous indentationpyclbr— Unterstützung für Python-Modulbrowserpy_compile— Compile Python source filescompileall— Byte-compile Python librariesdis— Disassembler for Python bytecodepickletools— Werkzeuge für Entwickler von pickle
- MS Windows-spezifische Dienste
- Unix-specific services
shlex— Simple lexical analysisposix— Die häufigsten POSIX-Systemaufrufepwd— Die Passwortdatenbankgrp— Die Gruppendatenbanktermios— tty-Steuerung im POSIX-Stiltty— Terminal control functionspty— Pseudo-terminal utilitiesfcntl— Thefcntlandioctlsystem callsresource— Resource usage informationsyslog— Unix syslog library routines
- Module mit Befehlszeilenschnittstelle (CLI)
- Superseded modules
- Entfernte Module
- Security Considerations