all Python 3platformfunction
platform.system()
system and machine
The OS name as a string: 'Linux', 'Windows', 'Darwin' (macOS), 'Java'; an empty string if unknown.
Syntax
platform.system()
macOS is called 'Darwin', not 'macOS', so system() == 'macOS' never matches. Unlike sys.platform ('linux', 'win32', 'darwin'), the value is capitalised and determined at run time rather than at build time; for branching that type checkers understand, sys.platform is the convention.
Examples
import platform
print(platform.system()) # → ? Linux, Windows или Darwin
print(platform.system() in {'Linux', 'Windows', 'Darwin'}) # → ? True на обычных ОС
print(platform.system() == 'macOS') # → False — macOS называется Darwin
See also
Open in the full glossarydocs.python.orgReport an inaccuracy