python2.7_1.3_获取远程设备的IP地址

代码如下:

# -*- coding: utf-8 -*-
import socket


def get_remote_machine_info():
    remote_host = 'www.python.org'
    try:
        print 'IP address:%s' % socket.gethostbyname(remote_host)
    except socket.error, err_msg:
        print '%s:%s' % (remote_host, err_msg)


if __name__ == '__main__':
    get_remote_machine_info()
    
原文地址:https://www.cnblogs.com/jsben/p/5166865.html