“Comment obtenir le nom d'hôte à partir d'IP Python” Réponses codées

Python obtient IP à partir du nom d'hôte

## importing socket module
import socket
## getting the hostname by socket.gethostname() method
hostname = socket.gethostname()
## getting the IP address using socket.gethostbyname() method
ip_address = socket.gethostbyname(hostname)
## printing the hostname and ip_address
print(f"Hostname: {hostname}")
print(f"IP Address: {ip_address}")
Friendly Falcon

Comment obtenir le nom d'hôte à partir d'IP Python

#This is how I got the hostname from the ip
import socket

# get input from user
input01 = input("\nType IP: ").upper() 

#gets information
output = socket.gethostbyaddr(str(input01))

#processes the information to only get the hostname
outputProceesed = str(output).split("'")[1::2]

#prints hostname
print(f"Their Hostname is {outputProceesed[0]}\n")
Fragile Fish

Réponses similaires à “Comment obtenir le nom d'hôte à partir d'IP Python”

Questions similaires à “Comment obtenir le nom d'hôte à partir d'IP Python”

Plus de réponses similaires à “Comment obtenir le nom d'hôte à partir d'IP Python” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code