morde08 / prettytable

Automatically exported from code.google.com/p/prettytable
Other
0 stars 0 forks source link

how to display "ambiguous" width in chinese character? #51

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
from prettytable import  PrettyTable
header="乘客姓名,性别,出生日期".split(",")

x = PrettyTable(header)
x.align["乘客姓名"]="l"
table='''HuangTianhui,男,1948/05/28
姜翠云,女,1952/03/27
李红晶,女,1994/12/09
LuiChing,女,1969/08/02
宋飞飞,男,1982/03/01
唐旭东,男,1983/08/03
YangJiabao,女,1988/08/25
买买提江·阿布拉,男,1979/07/10
安文兰,女,1949/10/20
胡偲婠(婴儿),女,2011/02/25
(有待确定姓名),男,1985/07/20
'''
data=[row for row in table.split("\n") if row]
for row in data:
    x.add_row(row.strip().split(","))

print(x)

Original issue reported on code.google.com by elearn2...@gmail.com on 28 Apr 2014 at 11:10

Attachments: