获得远程ip

import socket
remote_host='www.baidu.com'
try:
    print"IP address: %s" %socket.gethostbyname(remote_host)
except socket.error,err_msg:
    print"%s %s:" %(remote_host , err_msg)
原文地址:https://www.cnblogs.com/smghome/p/9528603.html