python 终端输出美观的表格
在做自动化测试的时候,有时候会有些需求在终端输出表格数据给用户展示,这时候就用到了PrettyTable,推荐给大家
首先需要 pip install prettytable
from prettytable import PrettyTable table = PrettyTable(["name", "age", "score"]) table.add_row(["a", "15", "90"]) table.add_row(["b", "17", "100"]) table.add_row(["c", "27", "100"]) table.add_row(["d", "45", "100"]) table.add_row(["e", "67", "100"]) print(table)