我怎样才能用python找到我的IP地址而不是本地IP?我尝试使用套接字,但它找到本地 ip。我需要以太网外部 ip。这是我的代码,但它找到本地 ip
import socket
hostname = socket.gethostname()
IPAddr = socket.gethostbyname(hostname)
print("Your Computer Name is:" + hostname)
print("Your Computer IP Address is:" + IPAddr)
Run Code Online (Sandbox Code Playgroud)