Python字符界面函数库

curses

ncurses

prettytable

from prettytable import PrettyTable

row = PrettyTable()

row.field_names = ["Name", "Age", "Country", "City"]    # 增加表头
row.add_row(['shaw', '23', 'China', 'Shanghai'])        # 增加行数据
row.add_row(['charle', '29', 'China', 'Xuzhou'])
row.add_row(['jack', '32', 'United States', 'Washington'])
print(row)

# 结果:
# +--------+-----+---------------+------------+
# |  Name  | Age |    Country    |    City    |
# +--------+-----+---------------+------------+
# |  shaw  |  23 |     China     |  Shanghai  |
# | charle |  29 |     China     |   Xuzhou   |
# |  jack  |  32 | United States | Washington |
# +--------+-----+---------------+------------+

 

posted @ 2016-06-04 21:36  每天进步一点点!!!  阅读(1215)  评论(0编辑  收藏  举报