If you need to get the Hostname in your Python application, then you can do the following:

Option 1 – Using gethostname()

1
2
import socket
print(socket.gethostname())

Option 2 – Using the platform module

1
2
import platform
print (platform.node())

Option 3 – Using os.uname()

1
2
3
import os
hname = os.uname()
print(hname)