python 学习札记-str.find() str.rfind()
python 学习笔记--str.find() str.rfind()
str.find() & str.rfind()
str.find(str, start=0 end=len(string))
Parameters:
Here is the detail of parameters:
-
str: specifies the string to be searched.
-
start : starting index, by default its 0
-
end : ending index, by default its equal to the lenght of the string
find()----找到的第一个符合字符的index
rfind()-----找到最后一个符合的字符的index
#/usr/bin/python absfile=r"/root/log/" index=absfile.find("/") index=absfile.rfind("/") print absfile print index
output:
9
0