mirror of
https://github.com/python/cpython.git
synced 2025-09-30 12:21:51 +00:00
Add a note to the str.find doc to suggest the use of the "in" operator.
This commit is contained in:
parent
01c9a16031
commit
87b86c84ef
1 changed files with 9 additions and 0 deletions
|
@ -944,6 +944,15 @@ string functions based on regular expressions.
|
||||||
*start* and *end* are interpreted as in slice notation. Return ``-1`` if
|
*start* and *end* are interpreted as in slice notation. Return ``-1`` if
|
||||||
*sub* is not found.
|
*sub* is not found.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
The :meth:`~str.find` method should be used only if you need to know the
|
||||||
|
position of *sub*. To check if *sub* is a substring or not, use the
|
||||||
|
:keyword:`in` operator::
|
||||||
|
|
||||||
|
>>> 'Py' in 'Python'
|
||||||
|
True
|
||||||
|
|
||||||
|
|
||||||
.. method:: str.format(*args, **kwargs)
|
.. method:: str.format(*args, **kwargs)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue