标签:http os ar sp art on c ef r
def all_index(l,o):
def find_index(l,o,start=0):
try:
index=l.index(o,start)
except:
index=-1
return index
indexs=[]
i=0
while True:
idx=find_index(l,o,i)
if idx==-1:
return indexs
indexs.append(idx)
i=idx+1
return indexs
a=‘sdffesafd‘
print all_index(a, ‘f‘)
python 得到一个元素的所有下标(网友提供:http://www.oschina.net/code/snippet_212212_38917)
标签:http os ar sp art on c ef r
原文地址:http://www.cnblogs.com/mhxy13867806343/p/3993385.html