📜  左填充零 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:54.638000             🧑  作者: Mango

代码示例1
print str(1).zfill(3);
# Expected output: 001

# Since python 3.6 you can use fstring :
number = 1
string_to_print = f"padded number: {number:05}"
print(string_to_print)

>>> padded number: 00001