how to get the ip in python code example
Example 1: get external ip python
from requests import get
ip = get('https://api.ipify.org').text
print 'My public IP address is:', ip
Example 2: get IP address python
import socket
hostname = socket.gethostname()
IPAddr = socket.gethostbyname(hostname)
print("Your Computer Name is:" + hostname)
print("Your Computer IP Address is:" + IPAddr)
Example 3: get ip python
import socket
host = socket.getfqdn()
addr = socket.gethostbyname(host)
print(f"Your ip is {addr}")
Example 4: how to get user ip in python
import socket
host_name = socket.gethostname()
IPAddress = socket.gethostbyname(host_name)
print("Your Computer Name is:" + host_name)
print("Your Computer IP Address is:" + IPAddress)