Python 连接到插座
我正在尝试连接到代理以查看它是活的还是死的,但我一直收到此错误Python 连接到插座,python,sockets,proxy,irc,Python,Sockets,Proxy,Irc,我正在尝试连接到代理以查看它是活的还是死的,但我一直收到此错误 arg = data.split( ) args = '' for index,item in enumerate(arg) : if index > 3: if args == '': args = item e
arg = data.split( )
args = ''
for index,item in enumerate(arg) :
if index > 3:
if args == '':
args = item
else :
args += ' ' + item
if data.find('!check') != -1:
nick = data.split('!')[ 0 ].replace(':','')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ip = args[1]
port = int(args[2])
try:
s.connect((ip, port))
s.send('PRIVMSG ' + chan + " :" ' its alive' + '\r\n')
except socket.error:
s.send('PRIVMSG ' + chan + " :" ' its dead' + '\r\n')
您给代码提供了哪些参数?
ValueError
告诉您试图将句点(
)转换为整数,这毫无意义。什么是args
?我们如何知道args[2]是什么?调试器是您的朋友…您的代码毫无意义,并且没有告诉我们任何有关“args”的信息。阅读我上面的评论并调试代码。你的信息不完整,不可信。是的,不知道数据是什么样子,所以其余的都没有任何意义。另外,您将args
视为代码后面的列表,但是for
循环会生成一个字符串。
port = int(args[2])
ValueError: invalid literal for int() with base 10: '.'