Skip to content

Commit ea62813

Browse files
[3.14] gh-106318: Add examples for str.rjust() method (GH-143890) (#145257)
Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
1 parent ff365eb commit ea62813

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Doc/library/stdtypes.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2504,6 +2504,19 @@ expression support in the :mod:`re` module).
25042504
done using the specified *fillchar* (default is an ASCII space). The
25052505
original string is returned if *width* is less than or equal to ``len(s)``.
25062506

2507+
For example:
2508+
2509+
.. doctest::
2510+
2511+
>>> 'Python'.rjust(10)
2512+
' Python'
2513+
>>> 'Python'.rjust(10, '.')
2514+
'....Python'
2515+
>>> 'Monty Python'.rjust(10, '.')
2516+
'Monty Python'
2517+
2518+
See also :meth:`ljust` and :meth:`zfill`.
2519+
25072520

25082521
.. method:: str.rpartition(sep, /)
25092522

@@ -2820,13 +2833,17 @@ expression support in the :mod:`re` module).
28202833
than before. The original string is returned if *width* is less than
28212834
or equal to ``len(s)``.
28222835

2823-
For example::
2836+
For example:
2837+
2838+
.. doctest::
28242839

28252840
>>> "42".zfill(5)
28262841
'00042'
28272842
>>> "-42".zfill(5)
28282843
'-0042'
28292844

2845+
See also :meth:`rjust`.
2846+
28302847

28312848
.. index::
28322849
single: ! formatted string literal

0 commit comments

Comments
 (0)