Mega Code Archive

 
Categories / Python / Buildin Function
 

Zfill()

# 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