python fstring格式未对齐是字体吗?

问题描述

这是我的代码

txt = f"[{o['idx']:<5}] : {o['k_output']:>8}  {o['r_output']:>8}%

但是正如您从图像中看到的那样,它们不是逐行对齐的?
是因为字体?

enter image description here

解决方法

代码看起来还可以。将字体更改为等距。

此代码:

o = {}
o['idx'] = 43
o['k_output'] = 2.54
o['r_output'] = 0
txt = f"[{o['idx']:<5}] : {o['k_output']:>8}  {o['r_output']:>8}%,"
print(txt)

o = {}
o['idx'] =7
o['k_output'] = 2.54
o['r_output'] = 0
txt = f"[{o['idx']:<5}] : {o['k_output']:>8}  {o['r_output']:>8}%,"
print(txt)

以等宽字体输出的礼物:

[43   ] :     2.54         0%,[7    ] :     2.54         0%,