Filesystem and I/O Modules

os

Exposes operating-system services including directory traversal, file descriptors, environment mappings and process-related operations. Prefer path-like objects and context-managed file streams for routine file work. Availability, permission rules and symbolic-link behavior depend on the platform.

Formal Syntax & Structure

python syntaxpython
import os

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
import osfrom tempfile import TemporaryDirectorywith TemporaryDirectory() as folder:    os.mkdir(os.path.join(folder, "reports"))    print(os.listdir(folder))
Python Reference