Getting hostname of the system using python

Sometimes we need to get the hostname of the system inside the python programme.

This is easy to get, though there are many ways to do it..

#!/usr/bin/env python

import socket

HostName = socket.gethostname()

print HostName

Leave a Reply