如何用python判斷列表中是否包含多個字串中的一個或多個?

數能工作室發表於2020-12-12
Links = ['Tom is a boy', 'Lucy is a girl', 'Tom is a boy,Lucy is a girl', 'they all like english!']
keywords= 'Tom,Lucy'
result = ['1' if any([w in l and w for w in keywords.split(',')]) else '0' for l in Links ]
result
['1', '1', '1', '0']

相關文章