Answers for "python detect os"

2

check the os in python

from sys import platform
if platform == "linux" or platform == "linux2":
    # linux
elif platform == "darwin":
    # OS X
elif platform == "win32":
    # Windows...
Posted by: Guest on June-18-2020
1

check os python

>>> import platform
>>> platform.system()
'Windows'
>>> platform.release()
'XP'
>>> platform.version()
'5.1.2600'
Posted by: Guest on March-16-2021
0

python os.name mac

>>> import os
>>> os.name
'posix'
>>> import platform
>>> platform.system()
'Linux'
>>> platform.release()
'2.6.22-15-generic'
Posted by: Guest on July-22-2020

Python Answers by Framework

Browse Popular Code Answers by Language