擅长:python、mysql、java
<pre><code>import re
looking_for = 'football'
in_text = 'The main reason that i play football is because i love football.'
without_punctuation = re.sub('[^a-zA-Z ]', '', in_text)
words = without_punctuation.split(' ')
for i, w in enumerate(words):
if w == looking_for:
print(i)
</code></pre>
<p>但是当然。标点符号将会成为一个问题,就像这里(关于“足球”)一样——所以我现在已经去掉了大部分标点符号。你知道吗</p>