What is platform.version() in Python?

Overview

The platform module in Python provides functions that access the underlying platform’s (operating system) information.

The platform.version() method returns the underlying operating system’s release version. This method returns an empty string if it cannot determine the operating system’s version.

Method syntax

platform.version()

Parameters

This method has no parameters.

Return value

This method returns the underlying system’s version.

Example

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

Explanation

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

Free Resources