format
zfill
ljust
指定した幅になるよう先頭をゼロで埋めます。
str.zfill(width)
下記の値を入力するとサンプルに即時反映されます。
code
print
code = "42" print(code.zfill(5)) # 00042 print(code.zfill(2)) # 42