python html generator

前端 未结 9 1511
轮回少年
轮回少年 2020-12-04 22:28

I am looking for an easily implemented html generator for python. I found this one

http://www.decalage.info/python/html

but there is no wa

相关标签:
9条回答
  • 2020-12-04 22:59

    There's the venerable HTMLGen by Robin Friedrich, which is hard to find but still available here (dated 2001, but HTML hasn't changed much since then ;-). There's also xist. Of course nowadays HTML generation, as Lennart points out, is generally better done using templating systems such as Jinja or Mako.

    0 讨论(0)
  • 2020-12-04 23:01

    Actually you can add any attribute such as id and class to objects in HTML.py (http://www.decalage.info/python/html).

    attribs is an optional parameter of Table, TableRow and TableCell classes. It is a dictionary of additional attributes you would like to set. For example, the following code sets id and class for a table:

    import HTML
    table_data = [
            ['Last name',   'First name',   'Age'],
            ['Smith',       'John',         30],
            ['Carpenter',   'Jack',         47],
            ['Johnson',     'Paul',         62],
        ]
    htmlcode = HTML.table(table_data, 
        attribs={'id':'table1', 'class':'myclass'})
    print htmlcode
    

    The same parameter can be used with TableRow and TableCell objects to format rows and cells. It does not exist for columns yet, but should be easy to implement if needed.

    0 讨论(0)
  • 2020-12-04 23:07

    Html generation or any text generatio,jinja is a powerful template engine.

    0 讨论(0)
提交回复
热议问题