In Python, how to get hostname as the command hostname
does on Linux?
In Python, you can get the hostname by the socket.gethostname() library function in the socket module:
import socket
hostname = socket.gethostname()
Reference: https://www.systutorials.com/dtivl/20/how-to-get-the-hostname-of-the-node?show=34#a34