简体   繁体   English

使用制表,如何将列表打印为单行而不是单列?

[英]Using tabulate, how to print a list as a single row instead of a single column?

With this code:使用此代码:

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

I get:我得到:

-
0
1
2
-

I would like to get:我想得到:

-  -  -
0  1  2
-  -  -

Any ideas?有任何想法吗?

Got it!知道了! This works:这有效:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM