- 论坛徽章:
- 30
|
回复 9# davie5201314
以后请一次性把需求说清楚
[root@test200 shell]# python xx.py
please input : IT
1 xiao IT 001
2 co IT 002
please input : kf
4 cai kf 004
please input : 005
5 tiao xs 005
please input : 4
4 cai kf 004
please input : xxoo
don't match it!
please input : tuichu
[root@test200 shell]# cat xx.py
with open('/root/shell/file') as f:
l = f.read().split("\n")
while(1):
a = raw_input("please input : ")
t=filter(lambda x: a in x.split(" "),l)
if(t):
print "\n".join(t)
elif a == "tuichu":
break
else:
print "don't match it!"
|
|