❮ os
❯
- platform
- os
python which OS are we running on (os, platform)
examples/os/which_os.py
import os import platform print("Name: ", os.name) print("System: ", platform.system()) print("Release: ", platform.release()) print("Architecture:", platform.architecture()) print("Machine: ", platform.machine()) print("Processor: ", platform.processor()) print("Release: ", platform.release()) print("Version: ", platform.version()) # On Windows: # nt # Windows # 10 if platform.system() != 'Windows': print("Uname: ", os.uname()) # On Windows uname is not available
- Linux
Name: posix System: Linux Release: 5.13.0-37-generic Architecture: ('64bit', 'ELF') Machine: x86_64 Processor: x86_64 Release: 5.13.0-37-generic Version: #42-Ubuntu SMP Tue Mar 15 14:34:06 UTC 2022 Uname: posix.uname_result(sysname='Linux', nodename='code-maven', release='5.13.0-37-generic', version='#42-Ubuntu SMP Tue Mar 15 14:34:06 UTC 2022', machine='x86_64')
- MacOSX
Name: posix System: Darwin Release: 20.6.0 Architecture: ('64bit', '') Machine: x86_64 Processor: i386 Release: 20.6.0 Version: Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 Uname: posix.uname_result(sysname='Darwin', nodename='FooBar', release='20.6.0', version='Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64', machine='x86_64')