From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 26 Feb 2026 13:48:04 +0000 (+0100) Subject: [3.14] gh-106318: Add examples for str.rjust() method (GH-143890) (#145257) X-Git-Tag: v3.14.4~237 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ea628136c04f0894425ba7fd64b87c0f7796f319;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-106318: Add examples for str.rjust() method (GH-143890) (#145257) Co-authored-by: Adorilson Bezerra --- diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 73d46d25c070..1e1ae7a129d5 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2504,6 +2504,19 @@ expression support in the :mod:`re` module). done using the specified *fillchar* (default is an ASCII space). The original string is returned if *width* is less than or equal to ``len(s)``. + For example: + + .. doctest:: + + >>> 'Python'.rjust(10) + ' Python' + >>> 'Python'.rjust(10, '.') + '....Python' + >>> 'Monty Python'.rjust(10, '.') + 'Monty Python' + + See also :meth:`ljust` and :meth:`zfill`. + .. method:: str.rpartition(sep, /) @@ -2820,13 +2833,17 @@ expression support in the :mod:`re` module). than before. The original string is returned if *width* is less than or equal to ``len(s)``. - For example:: + For example: + + .. doctest:: >>> "42".zfill(5) '00042' >>> "-42".zfill(5) '-0042' + See also :meth:`rjust`. + .. index:: single: ! formatted string literal