As maybe a alternative more portable [1] and efficient [2], actually you can just use str.ljust.

In [2]: '190'.ljust(8, '0')
Out[2]: '19000000'

In [3]: str.ljust?
Docstring:
S.ljust(width[, fillchar]) -> str

Return S left-justified in a Unicode string of length width. Padding is
done using the specified fill character (default is a space).
Type:      method_descriptor

[1] format is not present on old python versions. format specifier was added since Python 3.0 (see PEP 3101) and Python 2.6.

[2] reverse twice is an expensive operation.

Answer from Manoel Vilela on Stack Overflow
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › str › zfill.html
zfill — Python Reference (The Right Way) 0.1 documentation
Returns the numeric string left filled with zeros in a string of specified length. ... Required. Width of the padding field. ... A sign prefix is handled correctly. The original string is returned if width is less than or equal to len(str). >>> '350'.zfill(1) '350' >>> '350'.zfill(2) '350' ...
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.str.zfill.html
pandas.Series.str.zfill — pandas 3.0.5 documentation - PyData |
Strings in the Series/Index are padded with ‘0’ characters on the left of the string to reach a total string length width.
People also ask

Should I use zfill or an f-string?
Use zfill for an existing string and sign-aware text padding; use an f-string when the source is numeric and the complete output format is known.
🌐
pythonpool.com
pythonpool.com › home › tutorials › python zfill(): zero-pad strings, numbers, and signs
Python zfill(): Zero-Pad Strings, Numbers, and Signs
Does zfill preserve a plus or minus sign?
Yes. zfill inserts zeros after a leading plus or minus sign, so '-42'.zfill(5) becomes '-0042'.
🌐
pythonpool.com
pythonpool.com › home › tutorials › python zfill(): zero-pad strings, numbers, and signs
Python zfill(): Zero-Pad Strings, Numbers, and Signs
🌐
W3Schools
w3schools.com › python › ref_string_zfill.asp
Python String zfill() Method
The zfill() method adds zeros (0) at the beginning of the string, until it reaches the specified length.
🌐
Python Pool
pythonpool.com › home › tutorials › python zfill(): zero-pad strings, numbers, and signs
Python zfill(): Zero-Pad Strings, Numbers, and Signs
July 13, 2026 - zfill is string formatting: it pads on the left and inserts zeros after a leading sign, without changing the numeric value.
🌐
Tutorialspoint
tutorialspoint.com › python › string_zfill.htm
Python String zfill() Method
The Python String zfill() method is used to fill the string with zeroes on its left until it reaches a certain width; else called Padding. If the prefix of this string is a sign character (+ or -), the zeroes are added after the sign character
🌐
Note.nkmk.me
note.nkmk.me › home › python
Pad Strings and Numbers with Zeros in Python (Zero-padding) | note.nkmk.me
May 18, 2023 - Specify the length of the returned string. The original string will be right-justified, and the left side will be filled with zeros. s = '1234' print(s.zfill(8)) # 00001234 print(type(s.zfill(8))) # <class 'str'>
Find elsewhere
🌐
Codecademy
codecademy.com › docs › python › strings › .zfill()
Python | Strings | .zfill() | Codecademy
November 19, 2023 - The .zfill() method pads a string with zeros on the left to maintain a specific length.
🌐
datagy
datagy.io › home › python posts › python strings › python zfill & rjust: pad a string in python
Python zfill & rjust: Pad a String in Python • datagy
December 16, 2022 - The Python zfill method is a string method that returns a copy of the string left filled with the '0' character to make a character the length of a given width.
🌐
Python Engineer
python-engineer.com › posts › pad-zeros-string
How to pad zeros to a String in Python - Python Engineer
... It also shows how numbers can be converted to a formatted String with leading zeros. zfill is the best method to pad zeros from the left side as it can also handle a leading '+' or '-' sign.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-string-zfill
Python String zfill() - GeeksforGeeks
January 2, 2025 - zfill() method in Python is used to pad a string with zeros (0) on the left until it reaches a specified width.
🌐
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.Series.str.zfill.html
pandas.Series.str.zfill — pandas 3.0.5 documentation
Strings in the Series/Index are padded with ‘0’ characters on the left of the string to reach a total string length width.
🌐
Initial Commit
initialcommit.com › blog › python-zfill-method
Python zfill Method
November 1, 2021 - zfill() is a built-in string method in Python that is used for padding zeros to the left side of the string.
🌐
Learn By Example
learnbyexample.org › python-string-zfill-method
Python String zfill() Method - Learn By Example
April 20, 2020 - The zfill() method returns a copy of string left padded with ‘0’ characters to make a string of specified length.
🌐
AskPython
askpython.com › python › string › python-string-zfill
Python string zfill() - AskPython
August 6, 2022 - The Python string zfill() function belongs to the String class, and can only be used on string objects. This takes in width as a parameter, and pads zeros on a string’s left (start of the string) till the specified width is reached.
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.strings.zfill.html
numpy.strings.zfill — NumPy v2.1 Manual
strings.zfill(a, width)[source]# Return the numeric string left-filled with zeros. A leading sign prefix (+/-) is handled by inserting the padding after the sign character rather than before. Parameters: aarray-like, with StringDType, bytes_, or str_ dtype ·
🌐
w3resource
w3resource.com › pandas › series › series-str-zfill.php
Pandas Series: str.zfill() function - w3resource
May 20, 2026 - The str.zfill() function is used to pad strings in the Series/Index by prepending '0' characters. Strings in the Series/Index are padded with '0' characters on the left of the string to reach a total string length width.
🌐
Plus2Net
plus2net.com › python › string-zfill.php
zfill() : fills left of the string with zeors by Python
This guarantees a consistent 5-digit format across all employee numbers. The zfill() method makes it simple to enforce this padding for uniform ID lengths.