Python: What OS am I working on?

What do I require to consider to see if I'm on Windows, Unix, etc?

0
2019-05-03 18:00:41
Source Share
Answers: 3

For the document below's the outcomes on Mac :

>>> import os
>>> os.name
'posix'
>>> import platform
>>> platform.system()
'Darwin'
>>> platform.release()
'8.11.1'
0
2019-05-07 16:56:25
Source

Dang-- lbrandy defeat me to the strike, yet that does not suggest I can not give you with the system results for Vista!

>>> import os
>>> os.name
'nt'
>>> import platform
>>> platform.system()
'Windows'
>>> platform.release()
'Vista'
.

... and also I can not think no person's uploaded one for Windows 10 yet :

>>> import os
>>> os.name
'nt'
>>> import platform
>>> platform.system()
'Windows'
>>> platform.release()
'10'
.
0
2019-05-07 16:43:31
Source
>>> import os
>>> print os.name
posix
>>> import platform
>>> platform.system()
'Linux'
>>> platform.release()
'2.6.22-15-generic'
.

The result of platform.system() is as adheres to :

  • Linux : Linux
  • Mac : Darwin
  • Windows : Windows

See : platform — Access to underlying platform’s identifying data

0
2019-05-07 16:38:20
Source