导包
import prettytable as pt
创建 PrettyTable 对象
tb = pt.PrettyTable()
添加列名 tb.field_names
tb.field_names = ['列名1', '列名2','...','列名n']
添加值 tb.add_row
tb.add_row(['值1','值2','...','值n'])
打印输出
print(tb)
完整代码
import prettytable as pt
tb = pt.PrettyTable()
tb.field_names = ['列名1', '列名2','...','列名n']
tb.add_row(['值1','值2','...','值n'])
print(tb)
2021-01-16