第三方模块 - tabulate

tabulate

1 # -*- coding:utf-8 -*-
2 from tabulate import tabulate
3 li_data = [['王信鑫', '27', '13478683345'], ['马纤羽', '34', '13744234523'], ['叶梓萱', '24', '13813234245']]
4 
5 headers = ['name', 'age', 'phone']
6 print(tabulate(li_data, headers=headers, tablefmt='grid'))

+--------+-------+-------------+
| name | age | phone |
+========+=======+=============+
| 王信鑫 | 27 | 13478683345 |
+--------+-------+-------------+
| 马纤羽 | 34 | 13744234523 |
+--------+-------+-------------+
| 叶梓萱 | 24 | 13813234245 |
+--------+-------+-------------+

参考:https://www.programcreek.com/python/example/81248/tabulate.tabulate



posted @ 2018-03-06 23:15  Alice的小屋  阅读(948)  评论(3编辑  收藏  举报