本文整理匯總了Python中tabulate.TableFormat方法的典型用法代碼示例。如果您正苦於以下問題:Python tabulate.TableFormat方法的具體用法?Python tabulate.TableFormat怎麽用?Python tabulate.TableFormat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tabulate
的用法示例。
在下文中一共展示了tabulate.TableFormat方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_custom_tablefmt
# 需要導入模塊: import tabulate [as 別名]
# 或者: from tabulate import TableFormat [as 別名]
def test_custom_tablefmt():
"Regression: allow custom TableFormat that specifies with_header_hide (github issue #20)"
tablefmt = TableFormat(
lineabove=Line("", "-", " ", ""),
linebelowheader=Line("", "-", " ", ""),
linebetweenrows=None,
linebelow=Line("", "-", " ", ""),
headerrow=DataRow("", " ", ""),
datarow=DataRow("", " ", ""),
padding=0,
with_header_hide=["lineabove", "linebelow"],
)
rows = [["foo", "bar"], ["baz", "qux"]]
expected = "\n".join(["A B", "--- ---", "foo bar", "baz qux"])
result = tabulate(rows, headers=["A", "B"], tablefmt=tablefmt)
assert_equal(result, expected)
示例2: _addCustomTabulateTables
# 需要導入模塊: import tabulate [as 別名]
# 或者: from tabulate import TableFormat [as 別名]
def _addCustomTabulateTables():
"""Create a custom ARMI tables within tabulate."""
tabulate._table_formats["armi"] = tabulate.TableFormat(
lineabove=tabulate.Line("", "-", " ", ""),
linebelowheader=tabulate.Line("", "-", " ", ""),
linebetweenrows=None,
linebelow=tabulate.Line("", "-", " ", ""),
headerrow=tabulate.DataRow("", " ", ""),
datarow=tabulate.DataRow("", " ", ""),
padding=0,
with_header_hide=None,
)
tabulate.tabulate_formats = list(sorted(tabulate._table_formats.keys()))
tabulate.multiline_formats["armi"] = "armi"
# runLog makes tables, so make sure this is setup before we initialize the runLog