githubEdit

Python Built-in Modules

Overview of common built-in modules in Python's standard library.

Python ships with a large standard library. You import these modules just like your own files.

Common Examples

import math
import random
import os

math

import math
print(math.sqrt(81))  # 9.0
print(math.pi)        # 3.14159...

random

import random
print(random.randint(1, 6))
print(random.choice(["a", "b", "c"]))

os

import os
print(os.getcwd())
print(os.listdir("."))

datetime

Tip

Use help("modules") in the Python REPL to list available modules.

Next | Previous

Last updated