安装模块
pip install prettytable
使用:
from prettytable import PrettyTable
field_names = ("id",'姓名','头衔')
table = PrettyTable(field_names=field_names)
table.add_row(['100','小明','教授'])
print(table)
结果:
+-----+------+------+
| id | 姓名 | 头衔 |
+-----+------+------+
| 100 | 小明 | 教授 |
+-----+------+------+