python texttable表格输出

来源:互联网 发布:香港记者知乎 编辑:程序博客网 时间:2024/06/06 00:59


来源:https://github.com/bufordtaylor/python-texttable


from texttable import Texttable


table = Texttable()

table.set_deco(Texttable.BORDER)
table.set_cols_align(["l", "l", "l"])#require three  columns
table.set_cols_valign(["m", "m", "m"])
#table.set_chars(["","","",""])
table.set_cols_width([10,5,10])


table.add_rows([ #["Name", "Age", "Nickname"],
             #["Mr\nXavier\nHuon", 32, "Xav'"],
             #["Mr\nBaptiste\nClement", 1, "Baby"] ,
         ["Tom",32,"cat"],
         ["ancj",9,"hjasdg"],
         ["asdhjaskhd",109,"nash"]  ])
print(table.draw() + "\n")
0 0
原创粉丝点击