Zero-pad a string.

Description

Return a copy of the string left filled with ASCII '0' digits to make a string of length width.

Usage

1

Arguments

str

A character vector.

width

An integer.

Details

A leading sign prefix (+/-) is handled by inserting the padding after the sign character rather than before. The original string is returned if width is less than or equal to nchar(str).

Value

A character vector.

References

https://docs.python.org/3/library/stdtypes.html#str.zfill

Examples

1
2
3
pystr_zfill("42", 5)
pystr_zfill("-42", 5)
pystr_zfill("+42", 5)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.