Copyright © tutorialspoint.com

Python String zfill() Method

previous next


Description:

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

Syntax:

str.zfill(width)

Parameters:

Here is the detail of parameters:

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

Copyright © tutorialspoint.com