亲宝软件园·资讯

展开

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

那片依然海 人气:0
想了解Python实现的简单dns查询功能示例的相关内容吗,那片依然海在本文为您仔细讲解Python dns查询的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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,0,socket.SOCK_STREAM)
    print_array(*result)

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

加载全部内容

相关教程
猜你喜欢
用户评论