import socket
print(socket.gethostname())
This code uses the socket
module to print the hostname of the machine it is run on.
Explanation:
-
import socket
imports thesocket
module. -
socket.gethostname()
returns a string representing the hostname of the current machine. -
print(socket.gethostname())
prints the hostname on the console.
No comments:
Post a Comment