You are here : python_2stringstringzfill

string.zfill() - string

             

The method zfill() pads string on the left with zeros to fill width.


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


Syntax

str.zfill(width)


Example

#!/usr/bin/python

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

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


Output / Return Value

When we run above program, it produces following result −


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


Limitations


Alternatives / See Also


Reference