2011-04-09 57 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') 

當我運行這段代碼我得到這個錯誤:IRC殭屍類型錯誤(蟒蛇)

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

我怎樣才能解決這個問題?

回答

2

arg從哪裏來?你知道它應該包含什麼嗎?

arg顯然是一個列表,而不是一個字符串。嘗試用str(arg[0])替換arg,看看是否有效。