Python: What OS am I running on?
Use platform.system(). It returns Windows, Linux or Darwin (for OSX). Long Story There are 3 ways to get OS in Python, each with its own pro and cons: Method 1 >>> import sys >>> sys.platform 'win32' # could be 'linux', 'linux2, 'darwin', 'freebsd8' etc How this works ( source): Internally it calls OS APIs to get name of the OS as defined by OS.
https://stackoverflow.com/questions/1854/python-what-os-am-i-running-on/45679447