Python has a handful of different ways to determine what OS the program is running on:
os.nameplatform.system()sys.platform
What are the values of these on various platforms?
Python has a handful of different ways to determine what OS the program is running on:
os.nameplatform.system()sys.platformWhat are the values of these on various platforms?
Linux:
>>> import os
>>> os.name
'posix'
>>> import platform
>>> platform.system()
'Linux'
>>> import sys
>>> sys.platform
'linux2'
Mac OS:
>>> import os
>>> os.name
'posix'
>>> import platform
>>> platform.system()
'Darwin'
>>> import sys
>>> sys.platform
'darwin'
Windows:
>>> import os
>>> os.name
'nt'
>>> import platform
>>> platform.system()
'Windows'
>>> import sys
>>> sys.platform
'win32'
Cygwin:
>>> import os
>>> os.name
'posix'
>>> import platform
>>> platform.system()
'CYGWIN_NT-10.0'
>>> import sys
>>> sys.platform
'cygwin'