Python zfill () method
description
Python zfill () method returns a string that specifies the length of the original string right justified, zero-padded front.
grammar
zfill () method syntax:
str.zfill(width)
parameter
- width - Specifies the length of the string. The original string right justified, zero-padded front.
return value
Returns length of string.
Examples
The following example shows zfill () function to use:
#!/usr/bin/python str = "this is string example....wow!!!"; print str.zfill(40); print str.zfill(50);
Examples of the above output results are as follows:
00000000this is string example....wow!!! 000000000000000000this is string example....wow!!!