snippetpythonCriticalCanonical
How to identify which OS Python is running on
Viewed 0 times
howrunningidentifypythonwhich
Problem
What do I need to look at to see whether I'm on Windows or Unix, etc.?
Solution
>>> import os
>>> os.name
'posix'
>>> import platform
>>> platform.system()
'Linux'
>>> platform.release()
'2.6.22-15-generic'The output of
platform.system() is as follows:- Linux:
Linux
- Mac:
Darwin
- Windows:
Windows
See:
platform — Access to underlying platform’s identifying dataCode Snippets
>>> import os
>>> os.name
'posix'
>>> import platform
>>> platform.system()
'Linux'
>>> platform.release()
'2.6.22-15-generic'Context
Stack Overflow Q#1854, score: 1332
Revisions (0)
No revisions yet.