get system type in python

You can use the platform.system() method to get the system/OS type in Python:

main.py
import platform

system_type = platform.system()
print(system_type)
68 chars
5 lines

This will output something like "Windows", "Linux", "Darwin" (for macOS), etc. depending on the system you're running the code on.

Alternatively, you could use the os.name attribute to check if the system is Windows:

main.py
import os

system_type = os.name
if system_type == 'nt':
    print('Windows')
else:
    print('Not Windows')
109 chars
8 lines

You can also use platform.architecture() to get the system architecture:

main.py
import platform

arch = platform.architecture()
print(arch)
60 chars
5 lines

This will output something like ('64bit', 'WindowsPE') or ('64bit', 'ELF') depending on the system you're running the code on.

gistlibby LogSnag