(Python) gaierror: [Errno 11004] getaddrinfo failed

后端 未结 2 1763
执念已碎
执念已碎 2021-01-28 20:49
from Tkinter import *
import tkMessageBox, socket


root = Tk()
root.title(\"pynet v1.0\")
root.config(bg=\'black\')
root.resizable(0,0)   

text = Text()   
text1 = Tex         


        
相关标签:
2条回答
  • 2021-01-28 21:28

    Why are you adding CRLF (\r\n) to the hostname before looking it up?

    If removing that doesn't fix it, print out the exact text you're passing to gethostbyname to make sure it's a valid hostname.

    0 讨论(0)
  • 2021-01-28 21:38

    My guess is because you are using a hostname that has a trailing newline. At the time I write this answer, your code shows:

    def Info():
        targetip = socket.gethostbyname_ex(text1.get("1.0", END))
        text.insert(END, targetip)
    

    When you use the index END you get the extra newline that is added by the text widget. You need to strip that off or use the index "end-1c".

    0 讨论(0)
提交回复
热议问题