Note that neither is the correct way to do things now. Now we use string formatting, but a similar format exists.
Basically, use of the 0
means if your DATA is shorter than your WIDTH, it will zero-fill to fill the width.
>>> "{:8}".format(12)
' 12'
>>> "{:08}".format(12)
'00000012' # different when data is shorter than width
>>> "{:8}".format(1234567890)
'1234567890'
>>> "{:08}".format(1234567890)
'1234567890' # no difference when data is longer than width
In old-style string interpolation, this would be:
>>> "%8d" % 12
' 12'
>>> "%08d" % 12
'00000012'
>>> "%8d" % 1234567890
'1234567890' # still no change
>>> "%08d" % 1234567890
'1234567890' # when data is longer than width