网站IP地址打印机无法在python中工作

时间:2016-02-12 22:58:10

标签: python sockets

我的代码在这里

C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt

然后返回错误 ip=int(input("What website do u need the ip address from?")) ipad=socket.gethostbyname(ip) print("Thats websites ip is",ipad) wait=input("Press enter to exit") os.system('cls')

2 个答案:

答案 0 :(得分:1)

你有:

ip=int(input("What website do u need the ip address from?"))

因此,出于某种原因,您尝试将输入转换为整数,然后将其分配给名为" ip"的变量。如果您输入一个整数,那么您的错误就会消失 - 当然,如果您希望人们输入网站主机名,那就没用了。

每当出现这样的错误时,请停止,仔细准确地阅读错误消息并检查您的代码。不是您编写的思考的代码,而是屏幕上的内容。

答案 1 :(得分:0)

您无法将字符串' www.google.com'投射到int

此外,socket.gethostbyname(hostname)会将主机名转换为IPv4地址格式,因此其输入不是int,而是string