擅长:python、mysql、java
<p>最简单的方法是使用正则表达式。你知道吗</p>
<ol>
<li>首先我们在字符串中找到所有匹配项。你知道吗</li>
<li>然后我们计算一场比赛结束和下一场比赛开始之间的差值。你知道吗</li>
</ol>
<p>以下是代码:</p>
<pre><code>import re
string = 'hoouseeqwehouusseee'
word = 'house'
pattern = '+'.join(word)
list_of_word_indices = [(match.start(0), match.end(0)) for match in re.finditer(pattern, string)]
list_of_gap_lengthes = [list_of_word_indices[i+1][0] - list_of_word_indices[i][1]
for i in range(len(list_of_word_indices)-1)]
print(list_of_gap_lengthes)
</code></pre>
<p>作为回报,你会得到一份空白清单。在你的例子中是<strong>'[4]'</strong></p>
<p>希望有帮助。你知道吗</p>