I'm probably being really dumb but I can't resolve this error in a basic client script.
我可能真的很笨,但是我不能在一个基本的客户端脚本中解决这个错误。
import socket
ipaddr = ""
desipaddr = ""
desport = 9999
myclient = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def startclient(desipaddr):
desipadd = raw_input("[+] Enter chatserver IP: ")
desipaddr = str(desipadd)
return desipaddr
def otherclient(desipaddr, myclient, desport):
myclient.connect(desipaddr, desport)
datatosend = raw_input("[+]>>> ")
myclient.send(datatosend)
datatoberecv = myclient.recv(1024)
formatteddata = "[+] " + str(datatoberecv)
print formatteddata
def main():
startclient(desipaddr)
otherclient(myclient, desipaddr, desport)
main()
"Attribute Error: 'str' object has no attribute 'connect'
"属性错误:'str'对象没有属性'connect'
2 个解决方案
#1
1
You defined
您定义
def otherclient(desipaddr, myclient, desport):
But passed
但通过
otherclient(myclient, desipaddr, desport)
#2
1
You have the arguments to otherclient(myclient, desipaddr, desport)
reversed according to the function definition.
根据函数定义,您有对其他客户机(myclient、desipaddr、desport)的参数。
#1
1
You defined
您定义
def otherclient(desipaddr, myclient, desport):
But passed
但通过
otherclient(myclient, desipaddr, desport)
#2
1
You have the arguments to otherclient(myclient, desipaddr, desport)
reversed according to the function definition.
根据函数定义,您有对其他客户机(myclient、desipaddr、desport)的参数。