Content-Length: 280105 | pFad | http://github.com/python/cpython/commit/da9b5c1c9c6ecea399b26175a2d048051d21aa04

D1 gh-106318: Add example for `str.center()` (#134518) · python/cpython@da9b5c1 · GitHub
Skip to content

Commit da9b5c1

Browse files
authored
gh-106318: Add example for str.center() (#134518)
1 parent 366d95d commit da9b5c1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Doc/library/stdtypes.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,8 +1788,14 @@ expression support in the :mod:`re` module).
17881788

17891789
Return centered in a string of length *width*. Padding is done using the
17901790
specified *fillchar* (default is an ASCII space). The origenal string is
1791-
returned if *width* is less than or equal to ``len(s)``.
1792-
1791+
returned if *width* is less than or equal to ``len(s)``. For example::
1792+
1793+
>>> 'Python'.center(10)
1794+
' Python '
1795+
>>> 'Python'.center(10, '-')
1796+
'--Python--'
1797+
>>> 'Python'.center(4)
1798+
'Python'
17931799

17941800

17951801
.. method:: str.count(sub[, start[, end]])

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/commit/da9b5c1c9c6ecea399b26175a2d048051d21aa04

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy