Learn R Programming

pystr (version 2.0.0)

pystr_center: Center a string.

Description

Return str centered in a string of length width.

Usage

pystr_center(str, width, fillchar = " ")

Arguments

str
A character vector.
width
An integer.
fillchar
A character string.

Value

A character vector.

Details

Padding is done using the specified fillchar (default is an ASCII space). The original string is returned if width is less than or equal to nchar(str).

References

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

See Also

pystr_ljust, pystr_rjust

Examples

Run this code
pystr_center("center me", 15)
pystr_center("center me", 15, "*")

Run the code above in your browser using DataLab