我需要强制 python(2.7.5) 在构建 xml 文件时使用单词类
properties = ET.SubElement(head, "properties", class="model.View$PropertyList")
^
SyntaxError: invalid syntax
我试过''或“”
properties = ET.SubElement(head, "properties", "class"="hudson.model.View$PropertyList")
SyntaxError: keyword can't be an expression
如果我将其更改为另一个名称(foo),它会构建 xml:
<properties foo="hudson.model.View$PropertyList" />