- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python program to Display Hostname and IP address?
Python provides gethostname(),gethostbyname() two function. gethostname() retrives the standard host name for the local machine. gethostbyname() retrives host information corresponding to a host name from a host database.
Socket. gethostname() Socket. gethostbyname()
Step 1: use module socket. Step 2: use gethostname() retrives the standard host name for the local machine. Step 3: use gethostbyname() retrives host information corresponding to a host name from a host database.
# Display hostname andIP address import socket def host_IP(): try: hname = socket.gethostname() hip = socket.gethostbyname(hname) print("Hostname: ",hname) print("IP Address: ",hip) except: print("Unable to get Hostname and IP") # Driver code host_IP() #Function call
Hostname: Satyajit-PC IP Address: 192.168.1.66
- C# program to Display Hostname and IP address
- C Program to display hostname and IP address
- Program to display hostname and IP address C
- Java program to display Hostname and IP address
- Difference between Static IP Address and Dynamic IP Address
- Difference between MAC Address and IP Address
- Difference between IP Address and MAC Address
- Validate IP Address in Python
- C Program to validate an IP address
- Display the Host Name and IP Address on a Tkinter Window
- Python program to remove leading zeros from an IP address
- Python program to find the IP Address of the client
- Defanging an IP Address in Python
- How to display the IP Address of the Machine using C#?