擅长:python、mysql、java
<pre><code>def sim(haystack, needle):
if needle in haystack:
return needle
</code></pre>
<p>如果需要索引:</p>
<pre><code>def sim(haystack, needle):
index = haystack.index(needle) # throws ValueError when not found
return (index, index + len(needle))
</code></pre>