admin
2025-01-15 744a282d75d8da1e24ffcd9e18e34dd525d5be0e
strategy/kpl_api.py
@@ -388,8 +388,11 @@
    # 清理多余数据函数
    def check_and_remove_oldest_entry(self, max_entries):
        # 读取所有行并解析为 JSON 对象列表
        with open(self.file_path, 'r', encoding='utf-8') as file:
            lines = [json.loads(line.strip()) for line in file if line.strip()]
        if os.path.exists(self.file_path):
            with open(self.file_path, 'r', encoding='utf-8') as file:
                lines = [json.loads(line.strip()) for line in file if line.strip()]
        else:
            lines = []
            # 如果行数超过限制,移除最早的一些行
        if len(lines) >= max_entries: