标签:
[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‘
标签:
原文地址:http://www.cnblogs.com/cheerong/p/4266133.html