我刚刚掌握了这个 xist html 生成代码,并且我的文档的整体结构运行良好,但准备开始用它们的类来标记所有各种元素,以便稍后通过 CSS 设置样式。我正在努力弄清楚如何使用类属性标记元素。如果我做类似的事情...
with html.td() :
with xsc.addattr("class" ) :
+xsc.Text("ColumnHeader")
+xsc.Text( "Image Name" )
我会收到以下错误
Traceback ...
ll.xist.xsc.IllegalAttrError: no local attribute with Python name 'class' in <attrs class ll.xist.ns.html:td.Attrs with 32 attrs at 0x2a0bed8>
最佳答案
真的很微妙,你必须使用class_
来完成它。
with xsc.addattr("class_" ) :
或更紧凑
with html.td( class_="ColumnHeader" ) :
关于python - 如何在 XIST python 模块中设置元素类属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28910606/