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

后端 未结 7 1178
死守一世寂寞
死守一世寂寞 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:26

    Use tabulate

    from tabulate import tabulate
    
    table = [['one','two','three'],['four','five','six'],['seven','eight','nine']]
    
    print(tabulate(table, tablefmt='html'))
    

    Which produces the following output.

    one two three
    four five six
    seveneightnine

提交回复
热议问题