Search a list of strings for any sub-string from another list

前端 未结 5 365
挽巷
挽巷 2020-12-29 06:05

Given these 3 lists of data and a list of keywords:

good_data1 = [\'hello, world\', \'hey, world\']
good_data2 = [\'hey, man\', \'whats up\']
bad_data = [\'h         


        
5条回答
  •  时光说笑
    2020-12-29 07:09

    Are you looking for

    any( k in s for k in keywords )
    

    It's more compact, but might be less efficient.

提交回复
热议问题