我似乎有与prettytable良好的输出:
from prettytable import PrettyTablex = PrettyTable(dat.dtype.names)for row in dat: x.add_row(row)# Change some column alignments; default was 'c'x.align['column_one'] = 'r'x.align['col_two'] = 'r'x.align['column_3'] = 'l'
而且输出还不错。甚至还有一个
border开关,还有其他一些选择:
>>> print(x)+------------+---------+-------------+| column_one | col_two | column_3 |+------------+---------+-------------+| 0 | 0.0001 | ABCD || 1 | 1e-005 | ABCD || 2 | 1e-006 | long string || 3 | 1e-007 | ABCD |+------------+---------+-------------+>>> print(x.get_string(border=False)) column_one col_two column_3 0 0.0001 ABCD 1 1e-005 ABCD 2 1e-006 long string3 1e-007 ABCD



