本文實例講述了Python實現(xiàn)的簡單dns查詢功能。分享給大家供大家參考,具體如下:
#!/usr/bin/pythonimport sys,socketdef print_array(*arr):    array = arr    for item in array:        print item[4][0]print '''this script is for host resolveprint "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)更多關(guān)于Python相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Python Socket編程技巧總結(jié)》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》、《Python入門與進階經(jīng)典教程》及《Python文件與目錄操作技巧匯總》
希望本文所述對大家Python程序設(shè)計有所幫助。
新聞熱點
疑難解答