【问题标题】:IRC Bot TypeError (python)IRC 机器人类型错误(python)
【发布时间】:2011-08-02 05:05:05
【问题描述】:
  if data.find('!search') != -1:
     nick = data.split('!')[ 0 ].replace(':','')
     conn = httplib.HTTPConnection("www.md5.rednoize.com")
     conn.request("GET", "?q=" + arg) 
     response = conn.getresponse()
     data = response.read() 
     result = re.findall('<div id="result" >(.+?)</div', data)
     if result:
        sck.send('PRIVMSG ' + chan + result + '\r\n')
     else:
           sck.send('PRIVMSG ' + chan + " :" ' could not find the hash' + '\r\n')

当我运行这段代码时,我得到了这个错误:

conn.request("GET " + "?q=" + arg)
TypeError: cannot concatenate 'str' and 'list' objects

我该如何解决这个问题?

【问题讨论】:

    标签: python sockets irc typeerror


    【解决方案1】:

    arg 来自哪里?你知道它应该包含什么吗?

    arg 显然是一个列表,而不是一个字符串。尝试将arg 替换为str(arg[0]),看看是否可行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-28
      • 2013-11-30
      • 2015-11-21
      • 2015-01-21
      • 1970-01-01
      • 1970-01-01
      • 2018-12-31
      • 2017-05-13
      相关资源
      最近更新 更多