There's a code I found in internet that says it gives my machines local network IP address:
hostname = socket.gethostname()
local_ip = socket.gethostbyname(hostname)
but the IP it returns is 192.168.94.2 but my IP address in WIFI network is actually 192.168.1.107 How can I only get wifi network local IP address with only python? I want it to work for windows,linux and macos.
You can use this code:
or this to get public ip: