📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Python from Zero Modules and Imports

Modules and Imports

5 min read
Use import to load standard library modules like os, json, datetime, and re. from module import name imports specific items. Python's standard library covers most common tasks without installing anything extra.

Using Modules

import math
print(math.pi)           # 3.14159...
print(math.sqrt(25))     # 5.0

from datetime import datetime
print(datetime.now())

import os
print(os.getcwd())
os.makedirs("new_folder", exist_ok=True)

# Create your own module — save as mymodule.py
# def greet(name): return f"Hi, {name}"