Runtime and Context Modules

platform

Reports operating-system and Python implementation metadata. Values depend on environment and can be empty or unavailable; avoid using OS names as a substitute for feature detection. The example parses the interpreter version string without assuming a particular OS.

Formal Syntax & Structure

python syntaxpython
import platform

Return Value

module

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

Working Example

Example Snippetpython
import platformprint(platform.python_version_tuple()[0])
Python Reference