import time import os def tail_f(filename): with open(filename, 'r', encoding='utf-8') as f: # Move the cursor to the end of the file f.seek(0, os.SEEK_END) while True: line = f.readline() if not line: time.sleep(0.1) # Sleep briefly continue print(line, end='') if __name__ == "__main__": log_file = '选品日志log/选品日志.log' tail_f(log_file)