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

Overview

In Python, the platform module provides functions that access information of the underlying OS.

The platform.node() method is used to return the computer’s node name. This method returns an empty string if it’s not able to determine the computer’s node name.

Syntax

node()

Parameters

This method takes no parameters.

Return value

It returns the computer’s node name.

Example

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

Explanation

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

New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources