Python library to print forms using prettytable landscaping output

This article describes the use of Python libraries prettytable print form beautification output paper to tell you in great detail by the example code, has a certain value for references, you can refer a friend in need

pip install prettytable

Each time you add a row

from prettytable import PrettyTable
#  默认表头:Field 1、Field 2...
#  添加表头
table = PrettyTable(["URL", "参数", "值"])
#  add_row 添加一行数据
table.add_row(["http://aaa.com", "raskv", "dEBxcS5j"])
table.add_row(["http://bbb.com", "su", "626d5633583231794c6d4e6"])
table.add_row(["http://ccc.com", "pwd", "Ym1WM1gyMXlMbU5"])
#  默认居中对齐
#  设置"值"列,局左对齐 left首字母
table.align["值"] = 'l'
print(table)

Here Insert Picture Description
Each time you add a

from prettytable import PrettyTable
table = PrettyTable()
#  add_column 添加一列数据
table.add_column('===', ["URL", "参数", "值"])
table.add_column('第1列', ["http://aaa.com", "raskv", "dEBxcS5j"])
table.add_column('第2列', ["http://bbb.com", "su", "626d5633583231794c6d4e6"])
table.add_column('第3列', ["http://ccc.com", "pwd", "Ym1WM1gyMXlMbU5"])
#  设置"第3列",局右对齐 right首字母
table.align["第3列"] = 'r'
print(table)
from prettytable import PrettyTable
table = PrettyTable()
#  add_column 添加一列数据
table.add_column('===', ["URL", "参数", "值"])
table.add_column('第1列', ["http://aaa.com", "raskv", "dEBxcS5j"])
table.add_column('第2列', ["http://bbb.com", "su", "626d5633583231794c6d4e6"])
table.add_column('第3列', ["http://ccc.com", "pwd", "Ym1WM1gyMXlMbU5"])
#  设置"第3列",局右对齐 right首字母
table.align["第3列"] = 'r'
print(table)

Here Insert Picture Description
to sum up

The above is a Python small series to introduce the use of prettytable library print form beautification output function, we hope to help
content on more than how many, and finally to recommend a good reputation in the number of public institutions [programmers], there are learn a lot of old-timers

Skills, learning experience, interview skills, workplace experience and other share, the more carefully prepared the zero-based introductory information, information on actual projects,

The method has timed programmer Python explain everyday technology, to share some of the learning and the need to pay attention to small details
Here Insert Picture Description

Published 64 original articles · won praise 13 · views 50000 +

Guess you like

Origin blog.csdn.net/chengxun02/article/details/105151235