PyDocs

Nav

Python Runtime Services

str.center

builtins

method of str
  • str.center(width, fillchar=' ', /)
Return a centered string of length width.

Padding is done using the specified fill character (default is
a space).
1 Example
>>> 'Python'.center(10)
'  Python  '
>>> 'Python'.center(10, '-')
'--Python--'
>>> 'Python'.center(4)
'Python'
from the Python docs
See Also
No see-alsos for builtins/str.center
0 Notes
No notes for str.center