Str.find () str.rfind () "function: Similar to index, look for character" "English: R=" right| right, find= "look for" "Description: Return a new integer, find the location, found that there is no -1,index found to error"
In [190]:"The stars is not afraid to appear like fireflies.". Find ("vition")#does not exist return-1OUT[190]:-1In [192]:"The stars is not afraid to appear like fireflies.". Find ("a")#search from left to startOUT[192]: 6In [193]:"The stars is not afraid to appear like fireflies.". RFind ("a")#find from the rightOUT[193]: 32
Str.count (Sub[,start[,end]) "function: Count the number of occurrences of a specified character in a string, according to the starting and ending positions of the" English:count=> Statistics, case= "" Description: Returns the number of statistics to "
in [
"
man was a born child, the He power is the POW Er of growth.
. Count (" o ") # Count the number of ' O ' occurrences from the entire string out[79]: 5in []: man is a born child, the He power is the power of growth. ". Count (" o ", 0,11) # count the number of occurrences of ' o ' from position 0 to 11 OUT[80]: 1
Str.index (Sub[,start[,end]) Str.rindex (sub[,start[,end]) "function: from the left of the string to find, sub=" to find the substring, start= "starting position, starting from 0, end= > End of position "" English:index=> Index, r=>right| right "" Description: Returns the location of the found string in the source string and cannot find an error "
In [63]:" What is your do don't see". Index ("e")#The default looks from the left,OUT[63]: 11In [43]:" What is your do don't see". Rindex ("e")#from the right, start looking,OUT[43]: 26In [45]:" What is your do don't see". Rindex ("W", 1)#start at position 1 and find from the rightresult error in [46]:" What is your do don't see". Rindex ("D", 0,20))#from position 0 to 20 and find from rightOUT[46]: 17
Python string Method Lookup