处理线程中打开文件,每次读取一行并记录当前读取位置,没有下一行让出一秒
logfile = './logs/%s_%s.log' % (appName, time.strftime('%Y_%m_%d')) file = open(logfile, 'r', encoding='utf-8') while True: where = file.tell() line = file.readline() if not line: time.sleep(1) file.seek(where) else: send_data(conn, line.strip().encode('utf-8'))

 

相关文章:

  • 2021-11-11
  • 2021-07-17
  • 2022-12-23
  • 2021-05-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-13
  • 2021-07-10
  • 2021-08-14
  • 2021-07-26
相关资源
相似解决方案