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

相关文章:

  • 2022-12-23
  • 2021-05-04
  • 2022-01-29
  • 2022-01-10
  • 2022-02-06
  • 2022-03-09
  • 2021-07-23
  • 2022-12-23
猜你喜欢
  • 2022-01-20
  • 2021-12-16
  • 2022-12-23
  • 2022-02-09
  • 2022-03-04
相关资源
相似解决方案