def CreateGenerator(file):
with open(file,'r') as t:
t.seek(0,2)
while True:
line=t.readline()
if not line:
time.sleep(0.1)
continue
yield line
g=CreateGenetor(r'C:\Users\Runlog.log)
for i in g:
print(i)
script:
可以在cmd里面运行C:\python\Python1\Python1\Python1.py C:\Users\Runlog.log,可以不加路径,更新文件保存后便能获取到新增加的log