python以表格的形式输出

https://www.jianshu.com/p/82689c1e3247
prettytable ,输出表格显示,操作
pip install prettytable

import prettytable as pt

# tb = pt.PrettyTable( ["City name", "Area", "Population", "Annual Rainfall"])
tb = pt.PrettyTable()
tb.field_names = ["City name", "Area", "Population", "Annual Rainfall"]
tb.add_row(["Adelaide",1295, 1158259, 600.5])
tb.add_row(["Brisbane",5905, 1857594, 1146.4])
tb.add_row(["Darwin", 112, 120900, 1714.7])
tb.add_row(["Hobart", 1357, 205556,619.5])

print(tb)

python以表格的形式输出_第1张图片

你可能感兴趣的:(python以表格的形式输出)