Display number with leading zeros
In Python 2 (and Python 3) you can do:
print "%02d" % (1,)
Basically % is like
sprintf (see docs).
For Python 3.+, the same behavior can also be achieved with
For Python 3.6+ the same behavior can be achieved with f-strings: