Python Glossary Русский

all Python 3platformfunction

platform.machine()

system and machine

The machine's processor architecture as a string: 'x86_64', 'AMD64', 'arm64', 'aarch64'; an empty string if unknown.

Syntax

platform.machine()

The same architecture goes by different names: x86-64 is 'x86_64' on Linux and macOS but 'AMD64' on Windows; ARM64 is 'aarch64' on Linux and 'arm64' on macOS. A comparison against one string therefore breaks on the next system, so compare against a set of variants and lower-case the value.

Examples

import platform
print(platform.machine())  # → ? например x86_64, AMD64 или arm64
is_arm = platform.machine().lower() in {'arm64', 'aarch64'}
print(type(is_arm).__name__)  # → bool

See also

Open in the full glossarydocs.python.orgReport an inaccuracy