很简单的一道题,普通做法效果也很不错
class Solution:
def strStr(self, haystack, needle):
"""
:type haystack: str
:type needle: str
:rtype: int
"""
if haystack.count(needle) == 0:
return -1
else: return haystack.index(needle)