PyDocs

Nav

Python Runtime Services

str.zfill

builtins

method of str
  • str.zfill(width, /)
Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.
1 Example
>>> "42".zfill(5)
'00042'
>>> "-42".zfill(5)
'-0042'
from the Python docs
See Also
No see-alsos for builtins/str.zfill
0 Notes
No notes for str.zfill