S = "ILoveFishCom" # 主串
T = "FishC" # 子串
j = 0
i = 0
while (i < len(S) and j < len(T)):
if S[i] == T[j]:
i += 1
j += 1
else:
i = i - j + 1 # 指向上次位置的下一元素
j = 0
if j == len(T):
print("found!!!")
else:
print("Not found!!!")