找出字符串中第一个匹配项的下标
代码实现
class Solution:
    def strStr(self, haystack: str, needle: str) -> int:
        str1_length=len(haystack)
        str2_length=len(needle)
        for i in range(str1_length-str2_length+1):
            if haystack[i:i+str2_length]==needle:
                return i
        return -1
 
解题思路
 










