监听文件输入的例子

 1 def tail(filename):
 2     f = open(filename, encoding='utf-8')
 3     while 1:
 4         line = f.readline()
 5         if line.strip():
 6             yield line.strip()
 7 g = tail('file')
 8 for i in g:
 9     if 'python' in i:
10         print('***',i)
原文地址:https://www.cnblogs.com/lpgit/p/9338722.html