Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 连接到插座_Python_Sockets_Proxy_Irc - Fatal编程技术网

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: '.'