You can use the platform.system()
method to get the system/OS type in Python:
main.py68 chars5 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.py109 chars8 lines
You can also use platform.architecture()
to get the system architecture:
main.py60 chars5 lines
This will output something like ('64bit', 'WindowsPE')
or ('64bit', 'ELF')
depending on the system you're running the code on.
gistlibby LogSnag