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

posted @ 2021-01-16 10:23  CodeYaSuo  阅读(539)  评论(0编辑  收藏  举报