1
我將如何找到一個字符串中的子字符串的索引,而不使用find方法和索引方法?我需要循環還是使用len方法?如何找到一個子串的索引?
def substring_test(x,y):
if y in x:
r = True
else:
r = False
return r
t = input("Enter a string: ")
v = input("Enter a starting substring ")
result = substring_test(sentence, substring)
print(result)
哦好,感謝解釋它,我從來沒有理解如何現在我可以解釋 – Bob 2014-11-05 03:51:36
@Bob歡迎您:-)如果它可以幫助您,您可以[接受此答案](http://meta.stackexchange.com/a/5235)。 – thefourtheye 2014-11-05 03:54:11
當我穿過它時,不管是什麼 – Bob 2014-11-05 03:56:49