這篇文章主要介紹了Python實現的簡單dns查詢功能,結合實例形式分析了Python基於socket模組的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)
【相關推薦】
# 2. 利用Python實現Youku視訊批次下載功能實例
3. 分享python中and / or 的運算邏輯實例教學
以上是分享Python實作dns查詢功能實例的詳細內容。更多資訊請關注PHP中文網其他相關文章!