【问题标题】:PrettyTable format titlePrettyTable 格式标题
【发布时间】:2018-05-06 08:03:11
【问题描述】:

我想用值格式化漂亮表的标题,但我不能。

from prettytable import PrettyTable


name = "table 1"
table = PrettyTable()
owntitle  = "table name is {}".format(str(name))
table.title = owntitle 
table.field_names = ['Experiment', 'Value']
table.add_row(['bla', 3.14])
table.add_row(['baz', 42.0])

print(table)

有什么建议吗?

【问题讨论】:

    标签: python plot prettytable


    【解决方案1】:

    修复你的代码

    table.title = owntitle 
    

    在执行代码之前还要安装PTable

    pip install PTable
    

    【讨论】:

    • 这是一个错误..我在Q中更改它。
    • table.title = owntitle - 那是原始行
    • 以上代码的输出是什么?
    • 没有标题的表格
    • 安装 PTable 然后执行你的代码,查看更新的答案。
    猜你喜欢
    • 2016-05-21
    • 2018-12-26
    • 2019-09-24
    • 1970-01-01
    • 2014-01-19
    • 1970-01-01
    • 2013-09-07
    • 2011-07-21
    • 1970-01-01
    相关资源
    最近更新 更多