擅长:python、mysql、java
<p>您可以使用列表理解</p>
<pre><code>word_list1 = ["cccc", "bbbb", "aaa"]
def stem_text(text):
text = text.split()
temp = [word_list1[0] if i in word_list1 else i for i in text]
text = ' '.join(temp)
return text
stem_text("hello bbbb now aaa den kkk")
</code></pre>
<p>输出:</p>
<pre><code>'hello cccc now cccc den kkk'
</code></pre>