Standard Library Modules
Standard library modules are always available but must be imported to be used in client modules. To access them, use one of these formats:
import module, and fetch attribute names (module.name)from module import name, and use module names unqualified (name)from module import *, and use module names unqualified (name)
For instance, to use name argv
in the sys module, either use
import sys and name sys.argv, or use from
sys import argv and name argv.
There are many standard library modules; the following sections are not necessarily exhaustive, and aim to document only commonly used names in commonly used modules. See Python’s Library Reference for a more complete reference to standard library modules.
In all of the following module sections:
Listed export names followed by parentheses are functions that must be called; others are simple attributes (i.e., variable names in modules).
Module contents document the modules’ state Python 3.0; see Python manuals for information on attributes unique to version 2 or 3.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access