【发布时间】:2018-11-12 21:23:00
【问题描述】:
我有两个要打印的参数
print('{0:25}${2:>5.2f}'.format('object', 20))
但他们给出以下回应:
Traceback (most recent call last):
IndexError: tuple index out of range
但是当我将代码更改为以下内容时,我得到了所需的输出:
print('{0:25}${2:>5.2f}'.format('object', 20, 20))
我不明白为什么,因为我只有两组 {}。谢谢
【问题讨论】:
标签: python-3.x format tuples