我是新手程序员,试图制作解析xml并将其内容粘贴到频道上的irc bot。通常我会在google上找到我的答案,但这次我找不到我的答案。Python:TypeError:不能乘以类型'float'的非int的序列
q0tag = dom.getElementsByTagName('hit')[0].toxml()
q0 = q0tag.replace('<hit>','').replace('</hit>','')
q1 = (q0 * 1.2)
当我试图乘Q0它总是显示
TypeError: can't multiply sequence by non-int of type 'float'.
林试图使Q0整数或浮点数,但它只是让另一个错误
AttributeError: 'NoneType' object has no attribute 'replace'
Q0值是没有小数的整数。
+1用于提及XML解析器。 [ElementTree](http://docs.python.org/library/xml.etree.elementtree.html)和[minidom](http://docs.python.org/library/xml.dom.minidom.html)分别是也相当不错。 – vinnydiehl
我一开始做了,但删除了它。我意识到OP正在使用''xml.dom'',这可能是好的 – jterrace
是的,我刚才在评论后看到了这一点。无论如何,我会保持链接,因为有人可能会发现它们有用。 – vinnydiehl