mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-106318: Add example for str.count()
(#134519)
This commit is contained in:
parent
da9b5c1c9c
commit
1729468016
1 changed files with 11 additions and 1 deletions
|
@ -1805,8 +1805,18 @@ expression support in the :mod:`re` module).
|
|||
interpreted as in slice notation.
|
||||
|
||||
If *sub* is empty, returns the number of empty strings between characters
|
||||
which is the length of the string plus one.
|
||||
which is the length of the string plus one. For example::
|
||||
|
||||
>>> 'spam, spam, spam'.count('spam')
|
||||
3
|
||||
>>> 'spam, spam, spam'.count('spam', 5)
|
||||
2
|
||||
>>> 'spam, spam, spam'.count('spam', 5, 10)
|
||||
1
|
||||
>>> 'spam, spam, spam'.count('eggs')
|
||||
0
|
||||
>>> 'spam, spam, spam'.count('')
|
||||
17
|
||||
|
||||
.. method:: str.encode(encoding="utf-8", errors="strict")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue