An IP(Internet Protocol) address is an identifier assigned to each computer and other device(e.g., router, mobile, etc) connected to a TCP/IP network that is used to locate and identify the node in communication with other nodes on the network. IP addresses are usually written and displayed in human-readable notation such as 192.168.1.35 in IPv4(32-bit IP address).
This article focus on How to get IP address of your computer in python.
You have to first import socket library and then use
IP = socket.gethostbyname(hostname)
and then print the value of the ip into the print() function your IP address as output as shown in the program given below.
Your Computer Name is:pppContainer Your Computer IP Address is:10.98.162.168
Related Post : Java program to find IP address of your computer
This article is contributed by ajay0007. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Difference between MAC Address and IP Address
- Python program to find if two IP Address belongs to Same or Different Network
- Python program to validate an IP Address
- Python program to determine if the given IPv4 Address is reserved using ipaddress module
- Python program to determine if the given IP Address is Public or Private using ipaddress module
- Program to convert IP address to hexadecimal
- Display Hostname and IP address in Python
- Python | Remove leading zeros from an IP address
- Extracting MAC address using Python
- Check if email address valid or not in Python
- Python script to change MAC address of Linux machine
- Extract IP address from file using Python
- Python script to get device vendor name from MAC Address
- Python - Extract domain name from Email address
- Application to get address details from zip code Using Python
- How to validate MAC address using Regular Expression
- Address Resolution in DNS (Domain Name Server)
- Three address code in Compiler
- Address Calculation Sort using Hashing
- Logical and Physical Address in Operating System