If you need to get the Hostname in your Python application, then you can do the following:
Option 1 – Using gethostname()
import socket
print(socket.gethostname())
Option 2 – Using the platform
module
import platform
print (platform.node())
Option 3 – Using os.uname()
import os
hname = os.uname()
print(hname)