Python Glossary Русский

all Python 3platformterm

platform

module

Facts about the machine and interpreter: operating system, its version, CPU architecture and Python version.

Syntax

import platform

platform answers "where am I running" with strings for people and for branching: system() returns 'Linux', 'Darwin' or 'Windows'. For checks in code, sys.platform and sys.version_info are more reliable, cheaper and independent of external tools. Trap: on macOS system() returns 'Darwin', not 'macOS', and many functions return an empty string when the value cannot be determined.

Examples

import platform
print(platform.system())  # → ? Linux, Darwin или Windows
print(platform.machine())  # → ? например x86_64
print(platform.python_version_tuple()[0])  # → 3

See also

Open in the full glossarydocs.python.orgReport an inaccuracy