Find Computer IP Address using Python

IP Address

An Internet Protocol(IP) is a numeric label which is assigned to each device. This is the method or protocol by which message can be sent over the internet. IP Address is an unique Identity of an device by which it can be uniquely identify.

Code:

  1. import socket   
  2. hostname=socket.gethostname()   
  3. IPAddr=socket.gethostbyname(hostname)   
  4. print("Your Computer Name is:"+hostname)   
  5. print("Your Computer IP Address is:"+IPAddr)   
Output:

Introduction  In this blog, we will see how can we get IP Address of the computer using Python.  IP Address  An Internet Protocol(IP) is a numeric label which is assigned to each device. This is the method or protocol by which message can be sent over the internet. IP Address is an unique Identity of an device by which it can be uniquely identify.  Code:   1. import socket  2. hostname=socket.gethostname()  3. IPAddr=socket.gethostbyname(hostname)  4. print("Your Computer Name is:"+hostname)  5. print("Your Computer IP Address is:"+IPAddr)   Output:  *

 

Ebook Download
View all
Learn
View all
sourabhsomani.com