A simple example of dns query functionality implemented by Python

  • 2020-06-01 10:20:00
  • OfStack

This article illustrates the simple dns query functionality implemented by Python as an example. I will share it with you for your reference as follows:

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:
        host = raw_input("please input the host: ")
    except KeyboardInterrupt:
        print "\n",
    except :
        print "\n",
    if host == "break" or host == "":
    result = socket.getaddrinfo(host,None,0,socket.SOCK_STREAM)

For more information about Python, please check out the topics on this site: summary of Python Socket programming skills, summary of Python functions, summary of Python string manipulation skills, introduction and advanced classic course of Python and summary of Python files and directories.

I hope this article has been helpful to you in Python programming.

Related articles: