#!/use/bin/env pythonn
#_*_ coding:utf-8 _*_
import time
def Bre():
while True:
Bre_falg = raw_input("是否还要继续查找(y/n)")
if Bre_falg == 'y' or Bre_falg == 'n':
return Bre_falg
else:
print("您输入错误请重新输入!.......")
file = file('information.txt','r')
file_info = file.readlines()
file.close
print ("===========欢饮来到员工信息查询表=================\n\n\t\t请你愉快查询\n\n")
Bre_falg=''
while Bre_falg !='n':
while True:
information=raw_input('请输入你要查找的信息:')
if len(information)>2:
break
else:
print('您输入的信息太少,请在重新输入.....')
count_number=0
new_file_list=[]
for i in file_info:
if i.count(information)>0:
new_file_list.append(i.replace(information,"\033[42;31;1m%s\033[0m" % information))
count_number +=1
if count_number>0:
print("共查到:\033[42;31;1m%s\033[0m条信息" % count_number)
for i in new_file_list:
print i
else:
print("没有您要查找的信息")
Bre_falg=Bre()
for i in range(3):
print '''\033[31;5m谢谢使用员工信息查询系统,%s秒后,退出系统\033[0m''' % (3-i)
time.sleep(1)
exit("您一退出系统")
下面是文件information.txt
name:marry age:23 sex:man job:IT teh:12345678 mail:1253153
name:song dada age:23 sex:man job:HR teh:0988777 mail:14214
name:zhang sanfeng age:23 sex:man job:IT teh:987544 mail:09789
name:zhang wuji age:23 sex:man job:accountant teh:12349876 mail:16397
name:ling huchong age:23 sex:man job:IT teh:48645678 mail:126dfsf
name:xiaoping age:23 sex:man job:manager teh:7807554 mail:245454
name:li yuanfang age:23 sex:man job:IT teh:1356781 mail:126126
name:feng feng age:23 sex:man job:boss teh:12335436 mail:163163