【发布时间】:2015-03-16 15:27:07
【问题描述】:
我需要一种方法来打印多个不同长度的列表,作为相邻的列分隔的制表符,并且空单元格保持为空或包含一些填充字符(例如“-”)。
到目前为止,尝试的方法对于不同长度的列表都不起作用,并且 numpy 并没有像我预期的那样起作用。
总结一下:
listname = [[1,2,3],[4,5,6,7,8],[9,10,11,12]]
打印在 .txt 文件中:
1 4 9
2 5 10
3 6 11
- 7 12
- 8 -
【问题讨论】:
-
你应该看看 Python 字符串格式化docs.python.org/2/library/stdtypes.html#string-formatting
标签: python list multiple-columns