How to get OS information using Python

How to get OS information using Python

Get OS information
This 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(
>>> import platform
>>> platform.system()
>>> platform.release()
>>> platform.version()

The name of the operating system dependent module imported. The output of 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()
Last modified October 4, 2020