def tail(filename): f = open(filename,encoding='utf-8') while True: line = f.readline() if line.strip(): #strip()去掉空格/换行 yield line.strip()g = tail('1')for i in g: if 'python' in i: #监控含有python的语句 print('***',i)
本文共 308 字,大约阅读时间需要 1 分钟。
def tail(filename): f = open(filename,encoding='utf-8') while True: line = f.readline() if line.strip(): #strip()去掉空格/换行 yield line.strip()g = tail('1')for i in g: if 'python' in i: #监控含有python的语句 print('***',i)
转载于:https://www.cnblogs.com/wzc27229/p/11008899.html