mirror of
https://github.com/python/cpython.git
synced 2025-10-02 05:12:23 +00:00
[3.14] gh-106318: Add example for str.center()
(GH-134518) (#134571)
Co-authored-by: Blaise Pabon <blaise@gmail.com>
This commit is contained in:
parent
73967c4c01
commit
7efe67ae35
1 changed files with 7 additions and 1 deletions
|
@ -1788,8 +1788,14 @@ expression support in the :mod:`re` module).
|
||||||
|
|
||||||
Return centered in a string of length *width*. Padding is done using the
|
Return centered in a string of length *width*. Padding is done using the
|
||||||
specified *fillchar* (default is an ASCII space). The original string is
|
specified *fillchar* (default is an ASCII space). The original string is
|
||||||
returned if *width* is less than or equal to ``len(s)``.
|
returned if *width* is less than or equal to ``len(s)``. For example::
|
||||||
|
|
||||||
|
>>> 'Python'.center(10)
|
||||||
|
' Python '
|
||||||
|
>>> 'Python'.center(10, '-')
|
||||||
|
'--Python--'
|
||||||
|
>>> 'Python'.center(4)
|
||||||
|
'Python'
|
||||||
|
|
||||||
|
|
||||||
.. method:: str.count(sub[, start[, end]])
|
.. method:: str.count(sub[, start[, end]])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue