生成器-文件输入监听器
def monitor(filename): f = open(filename, encoding='utf-8') while 1: line = f.readline().strip() if line: yield line.strip() m_g = monitor('file') for i in m_g: print(i) # while 1: # print(m_g.__next__())
def monitor(filename): f = open(filename, encoding='utf-8') while 1: line = f.readline().strip() if line: yield line.strip() m_g = monitor('file') for i in m_g: print(i) # while 1: # print(m_g.__next__())