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 platformprint("platform.node() = %s" % (platform.node()))
Explanation
- Line 1: We import the
platformmodule. - Line 3: We use the
node()method to retrieve the system’s network name on which the code is run.