how to get local ip in python code example
Example 1: how to get local ip in python
import socket
local_ip = socket.gethostbyname(socket.gethostname)
print(f"[+] Your Local IP is : {local_ip}")
Example 2: get ip python
import socket
host = socket.getfqdn()
addr = socket.gethostbyname(host)
print(f"Your ip is {addr}")
# On Linux, it may give you the localhost address
Example 3: how to get local ip in python
import socket
local_ip = socket.gethostbyname(socket.gethostname())
print(f"[+] Your Local IP is : {local_ip}")