本文實(shí)例講述了Python實(shí)現(xiàn)的簡單dns查詢功能。分享給大家供大家參考,具體如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/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) |
希望本文所述對(duì)大家Python程序設(shè)計(jì)有所幫助。