prettytable 库(打印输出格式化)基础用法
导包
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
本文来自博客园,作者:CodeYaSuo,转载请注明原文链接:https://www.cnblogs.com/hany-postq473111315/p/14285097.html