import socket def get_hostname(IP): hostname = socket.gethostbyaddr(IP) return hostname