how to detect os in python code example
Example 1: python check is os is windows
from sys import platform
if platform == "linux" or platform == "linux2":
elif platform == "darwin":
elif platform == "win32":
Example 2: check os python
>>> import platform
>>> platform.system()
'Windows'
>>> platform.release()
'XP'
>>> platform.version()
'5.1.2600'
Example 3: python os.name mac
>>> import os
>>> os.name
'posix'
>>> import platform
>>> platform.system()
'Linux'
>>> platform.release()
'2.6.22-15-generic'