python 字符串find方法使用
字符串查找方法——find()
find()方法查找子字符串,若找到返回下标值,找不到返回-1。
find()方法语法:
str.find(str, beg=0, end=len(string))#str---需要索引的字符串;beg -- 开始索引,默认为0;end -- 结束索引,默认为字符串的长度
例如:
>>> str1="abcdabcdcc"
>>> str1.find("abc")
0
>>> str1.find("abc".
原创
2021-03-07 21:44:31 ·
1677 阅读 ·
0 评论