import sys, socket try: result = socket.gethostbyaddr("查询的IP") #查询完后获得一个元组 print (result) #打印元组 例如:('mon-node1', [], ['10.101.0.95']) for item in result[2]: print " " + item