首页 > 编程语言 > 详细

python--查询员工信息

时间:2015-02-01 21:50:50      阅读:369      评论:0      收藏:0      [点我收藏+]

[root@cheeron lesson1]# cat user.txt
cheeron python 409982294
forilen shell 12309865
XueLi JS 4321780
LiLei IT 48393022
Simith IT 2340987
Liudehua Python 1234567

staff.py:

#!/usr/bin/env python

staff_list = ‘user.txt‘

f = open(staff_list)

c = f.readlines()

while True:

  user_input = raw_input(‘\033[32;1mPls input sth to search:\033[0m ‘).strip()

  if len(user_input) == 0: continue

  for line in c:

    if user_input in line:

      print line

      break

  else:

    print ‘\033[31;1mnot a vaild input!\033[0m‘ 

技术分享

 

python--查询员工信息

原文:http://www.cnblogs.com/cheerong/p/4266133.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!