python 写的员工信息查询

#!/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

 

转载于:https://www.cnblogs.com/houchaoying/p/8657522.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值