Tutorials Point


  Python Basics
  Python Advanced
  Python Useful References
  Python Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

Python String zfill() Method


previous next AddThis Social Bookmark Button


Description:

This method pads string on the left with zeros to fill width.

Syntax:

str.zfill(width)

Parameters:

Here is the detail of parameters:

  • width: final width of the string. This is the width which we would get after filling zeros.

Return Value:

It returns padded string.

Example:

#!/usr/bin/python

str = "this is string example....wow!!!";

print str.zfill(40);
print str.zfill(50);

This will produce following result:

00000000this is string example....wow!!!
000000000000000000this is string example....wow!!!


previous next Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names