← Go Back

How to Get the Running Operating System

The os.name string contains one of the following values depending on the operating system Python is running on:

  • 'nt' (Windows).
  • 'posix' (POSIX systems and Linux distributions ).
  • 'java' (when the Python implementation is Jython).

>>> import os
>>> os.name

The platform standard module can return the name of the operating system in greater detail:

>>> import platform
>>> platform.platform()

>>> import platform
>>> platform.platform()

os platform

🐍 You might also find interesting: