Best way to format integer as string with leading zeros? [duplicate] September 21, 2022 by Tarik You can use the zfill() method to pad a string with zeros: In [3]: str(1).zfill(2) Out[3]: '01'