【python 进阶】获取用户机主机名

import socket
def getHost(ip):
    print(0,ip)
    try:
        result=socket.gethostbyaddr(ip)
        print(result)
        if result: return result[0], None
    except socket.herror,e:
        print(socket.herror,e)

ip_list = ['157.55.39.156','116.179.32.214','40.77.167.41']
for ip in ip_list:
    print(ip,' || ',getHost(ip),' || ',getHost(ip)[0]) 

【python 进阶】获取用户机主机名