#监听过滤的效果 def tail(filename): f = open(filename,encoding='utf-8') while 1: line = f.readline() if line.strip(): yield line.strip() q = tail('2019-9-1') for i in q: print(i)