How to get OS information using Python
How to get OS information using Python
NoteThis guide is written for Python 3
Get what OS you are running
You can get which OS you are running using os
module or platform
>>> import os
>>> print(os.name)
nt
>>> import platform
>>> platform.system()
'Windows'
>>> platform.release()
'10'
>>> platform.version()
'10.0.17134'
The name of the operating system dependent module imported.
The output of os.name
is as follows:
posix
nt
java
While the output of platform.system()
is as follows:
- Linux:
Linux
- Mac:
Darwin
- Windows:
Windows
If you want user readable data but still detailed, you can use platform.platform()
>>> import platform
>>> platform.platform()
'Windows-10-10.0.17134-SP0'
Last modified October 4, 2020