【问题标题】:Using tabulate, how to print a list as a single row instead of a single column?使用制表,如何将列表打印为单行而不是单列?
【发布时间】:2020-10-05 15:41:34
【问题描述】:

使用此代码:

from tabulate import tabulate
print(tabulate(["0", "1", "2"]))

我明白了:

-
0
1
2
-

我想得到:

-  -  -
0  1  2
-  -  -

有什么想法吗?

【问题讨论】:

  • 我试过print(tabulate([["0"], ["1"], ["2"]])),但我得到了相同的输出。

标签: python tabulate


【解决方案1】:

知道了!这有效:

print(tabulate([["0", "1", "2"]]))   # (Put the original list inside a list.)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-10
    • 1970-01-01
    • 2017-03-20
    • 2016-12-16
    • 1970-01-01
    • 1970-01-01
    • 2021-10-21
    • 2022-08-03
    相关资源
    最近更新 更多