python_Day3:自定义字符串find()

str:查找的字符串
l_str:目标字符串
mi:开始查找的索引,起始点

def my_find(str,l_str,mi):
    l = len(str)
    for i in range(mi,len(l_str)):
        if str[0] == l_str[i]:
            if str == l_str[i:i+l]:
                m_index = i
                break
        else:
            m_index = -1
    return m_index
s = '123sdas'
a = 's'
print(my_find(a,s,1))
3  

你可能感兴趣的:(pyhton学习笔记)