我试图获得一个左对齐的输出..但我一直遇到对齐问题。这是我的代码:
def print_report(symbol:str,strategy:str, alist1:list, alist2:list, alist3:list, alist4:list):
print('\nSYMBOL: ', symbol.upper())
print('STRATEGY: ', strategy)
print('\n''DATE CLOSING INDICATOR SIGNAL')
for i in range(0,len(alist1)):
print('{0:<0}{1:>13}{2:>15}{3:>15}'.format(alist1[i],alist2[i],alist3[i],alist4[i]))
输出应如下所示:
DATE CLOSING INDICATOR SIGNAL
2013-10-01 887.00 0.00
2013-10-02 887.99 0.00
2013-10-03 876.09 0.00
2013-10-04 872.35 0.00
2013-10-07 865.74 877.83 SELL
2013-10-08 853.67 871.17 SELL
2013-10-09 855.86 864.74 SELL
2013-10-10 868.24 863.17 BUY
2013-10-11 871.99 863.10 BUY
2013-10-18 1011.41 911.27 BUY
2013-10-21 1003.30 936.71 BUY
有没有更简单的方法来获得输出?或正确对齐它们?