我正在尝试用python制作irc bot。该机器人将解析 XML 并将其内容粘贴到频道上。这是我的代码的一部分
f = open("1.xml")
data = f.read()
f.close()
domi = parseString(data)
attackerbartag = domi.getElementsByTagName('bar')[0].toxml()
attackerbar = attackerbartag.replace('<bar>','').replace('</bar>','')
attackerbar = round(float(attackerbar)2)
defenderbar = 100 - attackerbar
attackertag = domi.getElementsByTagName('name')[1].toxml()
attacker = attackertag.replace('<name>','').replace('</name>','')
defendertag = domi.getElementsByTagName('name')[42].toxml()
defender = defendertag.replace('<name>','').replace('</name>','')
attackerpointtag = domi.getElementsByTagName('points')[1].toxml()
attackerpoint = attackerpointtag.replace('<points>','').replace('</points>','')
defenderpointtag = domi.getElementsByTagName('points')[6].toxml()
defenderpoint = defenderpointtag.replace('<points>','').replace('</points>','')
attackerdomtag = domi.getElementsByTagName('domination')[0].toxml()
attackerdom = attackerdomtag.replace('<domination>','').replace('</domination>','')
defenderdomtag = domi.getElementsByTagName('domination')[4].toxml()
defenderdom = defenderdomtag.replace('<domination>','').replace('</domination>','')
result = 'Div.1 :: %s [ %s p ] [ %s% ] [ %s Dom ] <--> [ %s Dom ] [ %s% ] [ %s p ] %s ::' % (attacker, attackerpoint, attackerbar, attackerdom, defenderdom, defenderbar, defenderpoint, defender)
return result
我得到了ValueError: unsupported format character ']' (0x5d).
我很确定我已经关闭了所有 [ ]
我尝试用 () 更改 [ ] 并且错误是ValueError: unsupported format character ')' (0x5d)
谁能告诉我我在哪里制作了嘘声?谢谢