首页 > 编程语言 > 详细

Python String find()

时间:2021-05-27 11:44:37      阅读:16      评论:0      收藏:0      [点我收藏+]

The find() method returns the lowest index of the substring if it is found in given string. If its is not found then it returns -1.

Syntax :

str.find(sub,start,end)

Parameters :

sub : It’s the substring which needs to be searched in the given string.
start : Starting position where sub is needs to be checked within the string.
end : Ending position where suffix is needs to be checked within the string.

NOTE : If start and end indexes are not provided then by default it takes 0 and length-1 as starting and ending indexes where ending indxes is not included in our search.

Returns:

returns the lowest index of the substring if it is found in given string. If it’s not found then it returns -1.

The find() method is similar to index(). The only difference is find() returns -1 if searched string is not found and index() throws an exception in this case.

Python String find()

原文:https://www.cnblogs.com/LilyLiya/p/14815731.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!