import socket
localip=socket.gethostbyname(socket.gethostname())
print (localip)
iplist=socket.gethostbyname_ex(socket.gethostname())
for i in iplist:
if i !=localip:
print ("external IP:%s"%i)
print(socket.gethostname())
如图:
时间: 2025-01-02 14:50:55