#!/usr/bin/env pythong #_*_ coding:utf-8 _*_ import re # data = [ ‘tantianran phone 118‘, ‘tanyongxing phone 110‘, ‘tansufen phone 119‘, ‘dengwenyi phone 118‘, ‘dengwenqing phone 520‘, ‘laowang phone 110‘, ‘zhongjianwei 112‘ ] def findes(user_input,data): sugge = [] pat = ‘.*‘.join(user_input) regex = re.compile(pat) for item in data: match = regex.search(item) if match: sugge.append(item) return sugge strs = raw_input(‘输入查找的字符:‘) print ‘查找结果‘ for i in findes(strs,data): print "\033[31m %s \033[0m" % i
时间: 2024-10-12 20:01:17