“So erhalten Sie Hostname von IP Python” Code-Antworten

Python bekommen IP von Hostname

## 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

So erhalten Sie Hostname von 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

Ähnliche Antworten wie “So erhalten Sie Hostname von IP Python”

Fragen ähnlich wie “So erhalten Sie Hostname von IP Python”

Weitere verwandte Antworten zu “So erhalten Sie Hostname von IP Python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen