微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Python实现的简单dns查询功能示例

本文实例讲述了Python实现的简单dns查询功能分享给大家供大家参考,具体如下:

#!/usr/bin/python
import sys,socket
def print_array(*arr):
    array = arr
    for item in array:
        print item[4][0]
print '''this script is for host resolve
print "Now this begin...
if you want to leave,please input "break"'''
while 1:
    try:
        host = raw_input("please input the host: ")
    except KeyboardInterrupt:
        print "\n",continue
    except :
        print "\n",continue
    if host == "break" or host == "":
        break
    result = socket.getaddrinfo(host,None,socket.soCK_STREAM)
    print_array(*result)

更多关于Python相关内容感兴趣的读者可查看本站专题:《Python Socket编程技巧总结》、《Python函数使用技巧总结》、《Python字符串操作技巧汇总》、《Python入门与进阶经典教程》及《Python文件与目录操作技巧汇总

希望本文所述对大家Python程序设计有所帮助。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐