Best way to format integer as string with leading zeros? [duplicate]

You can use the zfill() method to pad a string with zeros:

In [3]: str(1).zfill(2)
Out[3]: '01'

Leave a Comment