Skip to content

Commit 083477f

Browse files
[3.13] gh-106318: Add examples for str.rjust() method (GH-143890) (#145256)
Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
1 parent e418e33 commit 083477f

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
@@ -2353,6 +2353,19 @@ expression support in the :mod:`re` module).
23532353
done using the specified *fillchar* (default is an ASCII space). The
23542354
original string is returned if *width* is less than or equal to ``len(s)``.
23552355

2356+
For example:
2357+
2358+
.. doctest::
2359+
2360+
>>> 'Python'.rjust(10)
2361+
' Python'
2362+
>>> 'Python'.rjust(10, '.')
2363+
'....Python'
2364+
>>> 'Monty Python'.rjust(10, '.')
2365+
'Monty Python'
2366+
2367+
See also :meth:`ljust` and :meth:`zfill`.
2368+
23562369

23572370
.. method:: str.rpartition(sep, /)
23582371

@@ -2669,13 +2682,17 @@ expression support in the :mod:`re` module).
26692682
than before. The original string is returned if *width* is less than
26702683
or equal to ``len(s)``.
26712684

2672-
For example::
2685+
For example:
2686+
2687+
.. doctest::
26732688

26742689
>>> "42".zfill(5)
26752690
'00042'
26762691
>>> "-42".zfill(5)
26772692
'-0042'
26782693

2694+
See also :meth:`rjust`.
2695+
26792696

26802697
.. index::
26812698
single: ! formatted string literal

0 commit comments

Comments
 (0)