python - 如何在 XIST python 模块中设置元素类属性

标签 python html html-generation

我刚刚掌握了这个 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/

相关文章:

html - 删除 iframe 下方的空白

javascript - Angularjs 登录应用程序?

html - 如何为子元素分配属性?

javascript - 保存javascript生成的文档

python - 我如何使用 pandas 来透视这个基本表?

python - 如何修复 - 导入 keras 时出现 ImportError : DLL load failed,

python - 时间序列平稳性

c# - 可用于帮助生成 HTML 的工具/SDK 有哪些?

JavaScript 到 HTML

python - 查找给定位置的最接近的数字集