属性错误:“ str”对象没有属性“ port”

时间:2020-05-16 15:59:43

标签: python

我尝试运行此代码,但是没有用 有人可以帮我吗?

import socket
import sys
try:
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    print "The socket was created succesfully"
except socket.error as err:
    print "The creation of the socket failed due to error %s" %(err)
port = 80
try:
    host_ip = socket.gethostbyname('www.adress.com')
except socket.gaierror:
    print "An error occured while resolving the host"
    sys.exit()
s.connect((host_ip.port))
print "Succesfully connected to adress\
on port == %s" %(host_ip)

0 个答案:

没有答案