0%

如何在Python 3中使用零填充字符串

✔️ 从python 3.6开始,您可以使用fstring:

>>> length = 1
>>> print(f'length = {length:03}')
length = 001