我试图让输出打印得很好,这样它就更具可读性。这是我到目前为止所拥有的:
a = (4,4)
b = (25,75)
c = (8,9)
d = (88,4)
elements = [(a[0]*a[1], "= 4 x 4"),
(b[0]*b[1], "= 25 x 75"),
(c[0]*c[1], "= 8 x 9"),
(d[0]*d[1], "= 88 x 4")]
fmt = "{0:>4}" # Something along these lines, not specific
for i in elements:
print(fmt.format(i))
这是我得到的输出:
(16, '= 4 x 4')
(1875, '= 25 x 75')
(72, '= 8 x 9')
(352, '= 88 x 4')
我认识到我的“元素”元组非常草率,但这是迄今为止我能想到的最好的!我希望尝试将我的输出格式化为这样的可读性和可读性:
16 = 4 x 4
1875 = 25 x 75
72 = 8 x 9
352 = 88 x 4
谢谢您的帮助。