Answer the question
In order to leave comments, you need to log in
What is the correct way to work with socket.getbyhostname in a loop?
I have a text file which contains hostnames:
www.google.com
www.yandex.com
etc.
There is such a code
import socket
pathToAddressList = input('Type in path to .txt file with listed hosts')
addressList = open(pathToAddressList, 'r+')
for address in addressList:
print(socket.gethostbyname(address))
Traceback (most recent call last):
File "C:/Users/user/PycharmProjects/untitled/deleting directory/script.py", line 10, in <module>
print(socket.gethostbyname(address))
socket.gaierror: [Errno 11004] getaddrinfo failed
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question