ip address and host name
Used socket to get the ip address and host name. We kept the code inside try & except for exception handling.
The output will change based on your hosting server.
my_host = socket.gethostname()
my_ip = socket.gethostbyname(my_host)
print("Hostname : ",my_host)
print("IP : ",my_ip)
print("Unable to get Hostname and IP address")
PHP Script to display IP address.
All Built in Functions in Python bin() complex()
This article is written by plus2net.com team.