prettytable在终端或在浏览器中依然是强大又美观的构建输出。可以在终端输出类似于如下图的格式。
from prettytable import PrettyTable
def pretty_print():
trains=[[11,12,13,14,15,16],[21,22,23,24,25,26],[31,32,33,34,35,36]]
header='list1 list2 list3 list4 list5 list6'.split()
pt=PrettyTable()
pt._set_field_names(header)
for train in trains:
pt.add_row(train)
print(pt)
pretty_print()