Introduction
In this blog, I am going to explain how to find the IP address in Python. It will display the accurate name of the computer and the IP address.
What Is IP Address?
An Internet protocol address (IP address) is a numerical label, assigned to each device (e.g., computer, printer) participating in a computer network, which uses the internet protocol for the communication.
Simple Programming
- import socket
- hostname=socket.gethostname()
- IPAddr=socket.gethostbyname(hostname)
- print("Your Computer Name is:"+hostname)
- print("Your Computer IP Address is:"+IPAddr)
Explanation
In this blog, I displayed the name of the computer and the IP address in the Run module.
Output
==== RESTART: C:/Users/admn/AppData/Local/Programs/Python/Python35/ip.py ====
Your Computer Name is:DESKTOP-L3VQQKN
Your Computer IP Address is:192.168.1.101
>>>