标签:option 接口 blog mil lag desc prot 元素 port
getaddrinfo方法用于通过url解析dns
import sys,socket def dns_resolver(url): result = socket.getaddrinfo(url, None) print(result[0][4][0]) if __name__ == ‘__main__‘: dns_resolver(‘www.baidu.com‘)
socket.getaddrinfo(host, port[, family[, socktype[, proto[, flags]]]])
返回值:[(family, socktype, proto, canonname, sockaddr)]有元组组成的列表,元组里面包含5个元素,其中sockaddr是(host,port)
标签:option 接口 blog mil lag desc prot 元素 port
原文地址:http://www.cnblogs.com/luxiaojun/p/6259638.html