擅长:python、mysql、java
<p>如果我的两分钱很重要的话,我会把包含你在字典里要找的关键词的单子翻过来,这样你就不必不断地重复两个单子了。你知道吗</p>
<p>哦,我忘了看ath<a href="https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm" rel="nofollow noreferrer">this</a>Aho–Corasick算法,这可能对你有很大帮助</p>
<p>如果不感兴趣,请按以下步骤操作</p>
<p>1-如果要保留两个列表,请查看<a href="https://stackoverflow.com/questions/4843158/check-if-a-python-list-item-contains-a-string-inside-another-string">here</a></p>
<pre><code>matchers = ['investment', 'property', 'something', 'else', 'vest']
matching = [s for s in my_list if any(xs in s for xs in matchers)]
</code></pre>
<p>2-也许吧</p>
<pre><code>reduce((lambda x, y: x+len(filter((lambda z, x=y: z == x), list2))), list1, 0)
</code></pre>
<p>3-<a href="https://stackoverflow.com/questions/749342/search-a-list-of-strings-for-any-sub-string-from-another-list">this</a>听起来也很有趣,看起来是regex的一个很好的替代品</p>
<p>对于限制匹配数的其他要求,也许可以添加一个while循环,当匹配数达到时该循环中断。在使用字典的情况下,将要查找的单词作为键,并将其所有值设置为1,每次找到单词时都添加值,直到达到目标为止。你知道吗</p>