from collections
import deque
def search(lines, search_data, max_len=5):
find_data_list = deque(maxlen=max_len)
for i
in lines:
if search_data
in i:
find_data_list.append(search_data)
yield i,find_data_list
if len(find_data_list) ==
5:
return
path =
"/home/guo/PycharmProjects/hellotest/tst.csv"
with open(path)
as f:
for searchline, search_data_list
in search(f,
"16:00",
4):
for i
in search_data_list:
print(i, end=
"******")
print(searchline)
print(
"-" *
30)