Easiest way to turn a list into an HTML table in python?

后端 未结 7 1188
死守一世寂寞
死守一世寂寞 2020-12-05 00:40

lets say I have a list like so:

[\'one\',\'two\',\'three\',\'four\',\'five\',\'six\',\'seven\',\'eight\',\'nine\']

and I want to experiment

7条回答
  •  佛祖请我去吃肉
    2020-12-05 01:22

    another choice is prettytable:

    from prettytable import PrettyTable
    pt = PrettyTable()
    

    if you want to generate html format:

    print(pt.get_html_string())
    

    if only generate ascii format table:

    print(pt.get_string())
    

    pls refer to the official document: https://ptable.readthedocs.io/en/latest/tutorial.html for more option, eg enable different kinds of style.

    enjoy.

提交回复
热议问题