2011-04-09 5 views
0
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') 

Quand je lance ce code je reçois cette erreur:IRC Bot TypeError (python)

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

Comment puis-je résoudre ce problème?

Répondre

2

D'où vient arg? Savez-vous ce qu'il est censé contenir?

arg est apparemment une liste, pas une chaîne. Essayez de remplacer arg par str(arg[0]) et de voir si cela fonctionne.

Questions connexes