tail_shrz.py 459 B

1234567891011121314151617
  1. import time
  2. import os
  3. def tail_f(filename):
  4. with open(filename, 'r', encoding='utf-8') as f:
  5. # Move the cursor to the end of the file
  6. f.seek(0, os.SEEK_END)
  7. while True:
  8. line = f.readline()
  9. if not line:
  10. time.sleep(0.1) # Sleep briefly
  11. continue
  12. print(line, end='')
  13. if __name__ == "__main__":
  14. log_file = '扫货日志log/扫货日志.log'
  15. tail_f(log_file)