zfill(): pads a numeric string on the left with zeros : zfill « Buildin Function « Python






zfill(): pads a numeric string on the left with zeros

zfill(): pads a numeric string on the left with zeros
# It understands about plus and minus signs:

print '12'.zfill(5)

print '-3.14'.zfill(7)

print '3.14159265359'.zfill(5)

# Using the % operator looks like this:

import math
print 'The value of PI is approximately %5.3f.' % math.pi





           
       








Related examples in the same category