Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Get Hostname+ ip/
- # python3 HostNameIP.py
- import socket
- # Function to display hostname and
- # IP address
- def get_Host_name_IP():
- try:
- host_name = socket.gethostname()
- host_ip = socket.gethostbyname(host_name)
- print("Hostname : ", host_name)
- print("IP : ", host_ip)
- except:
- print("Unable to get Hostname and IP")
- # Driver code
- get_Host_name_IP() # Function call
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement