python Python - 列表中的单词

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python Python - 列表中的单词相关的知识,希望对你有一定的参考价值。

some_list = ['abc-123', 'def-456', 'ghi-789', 'abc-456']
if any("abc" in s for s in some_list):

# If you really want to get all the items containing abc, use
matching = [s for s in some_list if "abc" in s]

以上是关于python Python - 列表中的单词的主要内容,如果未能解决你的问题,请参考以下文章