mirror of
https://github.com/python/cpython.git
synced 2026-04-14 07:41:00 +00:00
[3.14] gh-106318: Add examples for str.partition() method (GH-142823) (#144611)
gh-106318: Add examples for str.partition() method (GH-142823)
(cherry picked from commit 432ddd99e2)
Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
This commit is contained in:
parent
2494a90fbc
commit
27baa1cd5d
1 changed files with 13 additions and 0 deletions
|
|
@ -2483,6 +2483,19 @@ expression support in the :mod:`re` module).
|
|||
after the separator. If the separator is not found, return a 3-tuple containing
|
||||
the string itself, followed by two empty strings.
|
||||
|
||||
For example:
|
||||
|
||||
.. doctest::
|
||||
|
||||
>>> 'Monty Python'.partition(' ')
|
||||
('Monty', ' ', 'Python')
|
||||
>>> "Monty Python's Flying Circus".partition(' ')
|
||||
('Monty', ' ', "Python's Flying Circus")
|
||||
>>> 'Monty Python'.partition('-')
|
||||
('Monty Python', '', '')
|
||||
|
||||
See also :meth:`rpartition`.
|
||||
|
||||
|
||||
.. method:: str.removeprefix(prefix, /)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue