正则表达式可能是解决此问题的最简单方法:
import reregex = re.compile('th.s')l = ['this', 'is', 'just', 'a', 'test']matches = [string for string in l if re.match(regex, string)]
正则表达式可能是解决此问题的最简单方法:
import reregex = re.compile('th.s')l = ['this', 'is', 'just', 'a', 'test']matches = [string for string in l if re.match(regex, string)]