#!/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
本文出自 “FA&IT运维-Q群:223843163” 博客,请务必保留此出处http://freshair.blog.51cto.com/8272891/1869828
原文:http://freshair.blog.51cto.com/8272891/1869828