# find()
a = 'love you'
b = 'you'
c = 'no'
print(a.find(b)) #5
print(a.find(c)) #-1
# rfind()
a = 'love you'
b = 'you'
c = 'no'
print(a.rfind(b)) #5
print(a.rfind(c)) #-1
# count()
a = 'love you do you love me'
b = 'you'
c = 'no'
print(a.count(b)) #2
print(a.count(c)) #0
def indexstr(str1,str2):
'''查找指定字符串str1包含指定子字符串str2的全部位置,以列表形式返回'''
lenth2=len(str2)
lenth1=len(str1)
indexstr2=[]
i=0
while str2 in str1[i:]:
indextmp = str1.index(str2, i, lenth1)
indexstr2.append(indextmp)
i = (indextmp + lenth2)
return indexstr2
Python+vue+elementui+django based enterprise IT asset management system (front and back end separation) graduation project
The wide application of the In
When using pip to install modules in Python, the following message appears: fatal error in launcher solution
python Use in pip When install