How to use re match objects in a list comprehension

后端 未结 5 1888
说谎
说谎 2020-12-12 14:03

I have a function to pick out lumps from a list of strings and return them as another list:

def filterPick(lines,regex):
    result = []
    for l in lines:
         


        
5条回答
  •  时光说笑
    2020-12-12 14:34

    >>> "a" in "a visit to the dentist" 
    True 
    >>> "a" not in "a visit to the dentist" 
    False
    

    That also works with a search query you're hunting down in a list

    `P='a', 'b', 'c'

    'b' in P` returns true

提交回复
热议问题