From b3acdf378542032b2f390ff8bc5955987691062e Mon Sep 17 00:00:00 2001 From: roger Date: Wed, 28 Jun 2023 17:59:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=9F=BA=E6=9C=AC=E6=9E=B6?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- orm/blue_forecast.py | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/orm/blue_forecast.py b/orm/blue_forecast.py index e02dc2b..8f4b6f5 100644 --- a/orm/blue_forecast.py +++ b/orm/blue_forecast.py @@ -45,18 +45,43 @@ def get_delta_blue(_blue_data): print(get_delta_blue(get_all_blue())) +def get_all_prv_blue_list(_all_data, _last_blue_list, _num): + all_prv_blue_list = [] + min_id, max_id = 1, _all_data[-1]['id'] # 获取最大和最小id + for n in range(len(_last_blue_list)): + # print(_last_blue_list[n]) + for _data in _all_data: + if _data['blue'] == _last_blue_list[n]: + _id = _data['id'] + _num - n + if min_id <= _id <= max_id: + # print(f"{_data['id']} - {_id}") + all_prv_blue_list.append(_id) + return sorted(set(all_prv_blue_list)) + + # 获取预测的数据 -def get_blue_forecast(_blue_data, _method, _num): +def get_blue_forecast(_all_data, _method, _num): last_blue = db_get_last_data()['blue'] if last_blue is False: return False + blue_id_list = [] + for _data in _all_data: + if _data['blue'] == last_blue: + blue_id_list.append(_data['id']) + print(blue_id_list) + min_id, max_id = 1, _all_data[-1]['id'] # 获取最大和最小id + """ + 当_num=3时 + 先取当前一期的蓝球号码,然后计算历史上相同蓝球出现的后一期蓝球 + 然后往前推一期,取这一期蓝球号码,统计这个号码后两期的蓝球(不包含后一期) + 然后再往前推一期,取这一期蓝球号码,统计这个号码后三期的蓝球(不包含后一期和后两期) + """ + if _method == 'prv': # 当前一期往前推num期,包含此期数据 - prv_blue_id_list = [] - for _data in _blue_data: - if _data['blue'] == last_blue: - print(_data) - prv_blue_id_list.append(_data['id']) + recent_blue_id_list = [d['blue'] for d in _all_data[-_num:]] + prv_blue_id_list = get_all_prv_blue_list(_all_data, recent_blue_id_list, _num) print(prv_blue_id_list) + elif _method == 'post': # 当前一期往后num期,不包含此期的数据 pass else: