#!/usr/bin/env python
#_*_ coding:utf-8 _*_
user_file = 'userlist.txt'
info = raw_input('Input the info to search: ')
f = file(user_file,'rb')
count = 0
for line in f.xreadlines():
line = line.strip('\n').split()
if info in line:
line = ["\033[31m %s \033[0m" % info if i == info else i for i in line]
for i in line:
print i,
print '\n'
count += 1
if count == 0:
print 'the info is not exists in your txt'
else:
print 'match %d lines'%(count)
f.close()
~
#_*_ coding:utf-8 _*_
user_file = 'userlist.txt'
info = raw_input('Input the info to search: ')
f = file(user_file,'rb')
count = 0
for line in f.xreadlines():
line = line.strip('\n').split()
if info in line:
line = ["\033[31m %s \033[0m" % info if i == info else i for i in line]
for i in line:
print i,
print '\n'
count += 1
if count == 0:
print 'the info is not exists in your txt'
else:
print 'match %d lines'%(count)
f.close()
~