【问题标题】:Why does beautifultable in python do not fit content to the table?为什么python中的beautifultable不适合表格的内容?
【发布时间】:2021-02-20 03:23:31
【问题描述】:

刚开始使用漂亮的表格包,在打印表格时,内容是一个字母一个字母地打印,而不是整个单词。当我运行示例代码时,列和行完全适合内容。我究竟做错了什么?请帮忙

table1 = BeautifulTable()
table1.rows.append([1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10])
table1.rows.append(f)
table1.rows.header = ["VR[V]", "Frequency[kHz]"]
table1.columns.header = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"]
print(table1)

table = BeautifulTable()
table.rows.append(["Jacob", 1, "boy"])
table.rows.append(["Isabella", 1, "girl"])
table.rows.header = ["S1", "S2"]
table.columns.header = ["name", "rank", "gender"]
print(table)

unfitted table

fitted table

【问题讨论】:

    标签: python python-beautifultable


    【解决方案1】:

    您的问题是BeautifulTable 的构造函数采用名为maxwidth 的参数,并且该值默认为80。要解决您的问题,只需将该值设置为更大的值。如果您不希望数据包含在列中,请将其设置为非常大的值,例如:

    table1 = BeautifulTable(maxwidth=4000)
    

    我相信这会给你带来你想要的结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-12-26
      • 1970-01-01
      • 2012-08-12
      • 1970-01-01
      • 1970-01-01
      • 2013-09-16
      • 2020-09-13
      相关资源
      最近更新 更多