开发者

IRC Bot TypeError (python)

  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',开发者_如何学JAVA data)
     if result:
        sck.send('PRIVMSG ' + chan + result + '\r\n')
     else:
           sck.send('PRIVMSG ' + chan + " :" ' could not find the hash' + '\r\n')

When I run this code I get this error:

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

How can I fix this?


Where does arg come from? Do you know what it's supposed to contain?

arg is apparently a list, not a string. Try replacing arg with str(arg[0]) and see if that works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜