我想使用 tabulate 打印列表,但出现错误
I want to print a tabulated list using tabulate, but gives me error
list02 = [[101, 75.00, 69.31, 19, 'FAR'],
[102, 75.00, 68.71, 19, 'FAR'],
[103, 75.00, 67.55, 18, 'MIA'],
[104, 75.00, 65.41, 18, 'FSD'],
[105, 74.00, 64.39, 18, 'FAR'],
[106, 73.00, 63.36, 17, 'CLT']]
from tabulate import tabulate
print(tabulate(list02, headers=["Line#", "Credit", "Hrs", "Days Off", "ARP"]))
错误已修复!
但现在要求像值一样在右侧列出右侧的列。
Line# Credit Hrs Days Off Overnight
------- -------- --------- ---------- -----------
101 75 69.31 19 FAR
102 75 68.71 19 FAR
103 75 67.55 18 MIA
104 75 65.41 18 FSD
105 74 64.39 18 FAR
106 73 63.36 17 CLT
在 Spyder IDE
上使用 Python 3.8 运行
提前感谢您的帮助!
**最近编辑 --> 新问题!
list02 = [[101, 75.00, 69.31, 19, 'FAR'],
[102, 75.00, 68.71, 19, 'FAR'],
[103, 75.00, 67.55, 18, 'MIA'],
[104, 75.00, 65.41, 18, 'FSD'],
[105, 74.00, 64.39, 18, 'FAR'],
[106, 73.00, 63.36, 17, 'CLT']]
from tabulate import tabulate
print(tabulate(list02, headers=["Line#", "Credit", "Hrs", "Days Off", "ARP"]))
list02 = [[101, 75.00, 69.31, 19, 'FAR'],
[102, 75.00, 68.71, 19, 'FAR'],
[103, 75.00, 67.55, 18, 'MIA'],
[104, 75.00, 65.41, 18, 'FSD'],
[105, 74.00, 64.39, 18, 'FAR'],
[106, 73.00, 63.36, 17, 'CLT']]
from tabulate import tabulate
print(tabulate(list02, headers=["Line#", "Credit", "Hrs", "Days Off", "ARP"]))
错误已修复!
但现在要求像值一样在右侧列出右侧的列。
Line# Credit Hrs Days Off Overnight
------- -------- --------- ---------- -----------
101 75 69.31 19 FAR
102 75 68.71 19 FAR
103 75 67.55 18 MIA
104 75 65.41 18 FSD
105 74 64.39 18 FAR
106 73 63.36 17 CLT
在 Spyder IDE
上使用 Python 3.8 运行提前感谢您的帮助!
**最近编辑 --> 新问题!
list02 = [[101, 75.00, 69.31, 19, 'FAR'],
[102, 75.00, 68.71, 19, 'FAR'],
[103, 75.00, 67.55, 18, 'MIA'],
[104, 75.00, 65.41, 18, 'FSD'],
[105, 74.00, 64.39, 18, 'FAR'],
[106, 73.00, 63.36, 17, 'CLT']]
from tabulate import tabulate
print(tabulate(list02, headers=["Line#", "Credit", "Hrs", "Days Off", "ARP"]))