Skip to content

Commit aa2c0c3

Browse files
authored
gh-106318: Add examples for str.rjust() method (#143890)
1 parent 812ef66 commit aa2c0c3

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

@@ -2828,13 +2841,17 @@ expression support in the :mod:`re` module).
28282841
than before. The original string is returned if *width* is less than
28292842
or equal to ``len(s)``.
28302843

2831-
For example::
2844+
For example:
2845+
2846+
.. doctest::
28322847

28332848
>>> "42".zfill(5)
28342849
'00042'
28352850
>>> "-42".zfill(5)
28362851
'-0042'
28372852

2853+
See also :meth:`rjust`.
2854+
28382855

28392856
.. index::
28402857
single: ! formatted string literal

0 commit comments

Comments
 (0)