擅长:python、mysql、java
<p>假设正则表达式执行所需的操作,可以这样做以避免在迭代时删除。在</p>
<pre><code>import re
def checkio(text):
text = re.sub('[,\.\?\!]', ' ', text).lower()
words = [w for w in text.split() if not re.search(r'\d', w)]
print words ## prints [] in this case
</code></pre>
<p>另外,请注意,我简化了您的<code>text = text.replace(...)</code>行。在</p>
<p>另外,如果不需要重用<code>text</code>变量,可以使用regex直接拆分它。在</p>
^{pr2}$