You need to convert the numeric value to string and then you apply the method zfill() on the string to pad it with zeros on the left.
E.g.
>>> str(12).zfill(5)
'00012'
If you want to right-justify a string, you can use the method rjust() to pad it with spaces on the left.
E.g.
>>> str(12).rjust(5)
' 12'