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.
- 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 IP Address is Public or Private using ipaddress module
- Python program to determine if the given IPv4 Address is reserved using ipaddress module
- Program to convert IP address to hexadecimal
- Extracting MAC address using Python
- Extract IP address from file using Python
- Display Hostname and IP address in Python
- Python | Remove leading zeros from an IP address
- Check if email address valid or not in Python
- Python script to get device vendor name from MAC Address
- Python script to change MAC address of Linux machine
- Python program to find the first day of given year
- Python program to find all possible pairs with given sum
- Difference between MAC Address and IP Address
- Python program to find the sum of all items in a dictionary
- Python program to Find the Jumbo GCD subarray
- Python program to find day of the week for a given date
- Python program to find birthdate on the same day you were born
- Python program to find second maximum value in Dictionary