What is the platform.system() method in Python?

Overview

The platform module in python provides functions that access information of the underlying platform (operating system).

The platform.system() method is used to return the underlying operating system name. This method returns an empty string if it’s not able to determine the operating system name, for example, Linux or Windows.

Method signature

Let’s view the signature of this method.

system()

Parameters

This method has no parameters.

Return value

The return value is the operating system name.

Code

Let’s view the code of this method.

import platform
print("platform.system() = %s" % (platform.system()))

Explanation

  • Line 1: We import the platform module.
  • Line 3: We use the system() method to retrieve the operating system’s name, on which the code is run.

Free Resources