https://github.com/python/cpython/commit/3c8c4e98dabe00e9ff8583142e7d9f1c140df7e1 commit: 3c8c4e98dabe00e9ff8583142e7d9f1c140df7e1 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: encukou <[email protected]> date: 2026-01-13T12:22:49Z summary:
[3.14] gh-106318: Add examples for str.replace() method (GH-143581) (GH-143789) (cherry picked from commit af9f783a7e9bfdca94ce5b9619c1b82a32d9e170) Co-authored-by: Adorilson Bezerra <[email protected]> files: M Doc/library/stdtypes.rst diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 6842add0acb11e..85e42876e2faf8 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2512,6 +2512,14 @@ expression support in the :mod:`re` module). Return a copy of the string with all occurrences of substring *old* replaced by *new*. If *count* is given, only the first *count* occurrences are replaced. If *count* is not specified or ``-1``, then all occurrences are replaced. + For example: + + .. doctest:: + + >>> 'spam, spam, spam'.replace('spam', 'eggs') + 'eggs, eggs, eggs' + >>> 'spam, spam, spam'.replace('spam', 'eggs', 1) + 'eggs, spam, spam' .. versionchanged:: 3.13 *count* is now supported as a keyword argument. _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
