IRC 机器人类型错误 (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', 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
我该如何解决此问题?
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')
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
arg
从哪里来?你知道它应该包含什么吗?arg
显然是一个列表,而不是一个字符串。尝试用str(arg[0])
替换arg
并查看是否有效。Where does
arg
come from? Do you know what it's supposed to contain?arg
is apparently a list, not a string. Try replacingarg
withstr(arg[0])
and see if that works.