-
Notifications
You must be signed in to change notification settings - Fork 175
Closed
Description
Hi,
My code is like this:
from tabulate import tabulate
res = [{'object': '1986', 'relation': '出生日期', 'subject': '爱德华·尼科·埃尔南迪斯'}, {'object': '哥伦比亚', 'relation': '国籍', 'subject': '爱德华·尼科·埃尔南迪斯'}, {'object': '70公分', 'relation': '身高', 'subject': '爱德华·尼科·埃尔南迪斯'}]
title = ['subject', 'relation', 'object']
tbl = [title] + [[el['subject'], el['relation'], el['object']] for el in res]
tbl = tabulate(tbl, headers='firstrow', tablefmt='orgtbl', colalign=('right',))
print(tbl)And the result is:
| subject | relation | object |
|--------------+------------+----------|
| 爱德华·尼科·埃尔南迪斯 | 出生日期 | 1986 |
| 爱德华·尼科·埃尔南迪斯 | 国籍 | 哥伦比亚 |
| 爱德华·尼科·埃尔南迪斯 | 身高 | 70公分 |
How could I make the column aligns well ?
danieljuschus
Metadata
Metadata
Assignees
Labels
No labels