监控文件

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