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)
2023-10-02 11:09:46
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)