快乐8组合统计代码的使用方法

泽江东旭侯 2024-10-21 12:51:32
快乐8组合统计代码的使用方法

很多朋友来问我是如何统计快乐8的号码组合的,比如两码组合,三码组合,五码同出组合等等。

其实,我很早就给大家共享了快乐8的组合同出统计代码。

from collections import Counterfrom itertools import combinationsimport random# 快乐8的红球历史数据red_balls_history =[[7,16,22,27,28,34,37,38,39,40,45,46,51,57,63,64,65,73,77,80],[3,5,9,13,20,23,28,31,32,36,42,43,44,49,63,66,68,69,75,76],[9,13,14,18,22,28,33,35,41,45,48,49,51,53,58,68,71,73,74,80],[4,7,9,11,12,16,19,20,25,27,28,37,42,52,60,64,66,69,71,78],[2,3,6,13,14,19,21,22,32,49,52,53,60,68,69,70,71,73,74,75],[7,13,19,20,23,26,39,40,41,55,57,61,62,63,65,66,71,73,76,79],[3,12,16,21,23,25,32,39,40,41,52,54,65,67,68,73,74,75,76,77],[3,5,8,10,11,13,14,26,27,30,32,34,46,48,49,51,68,72,75,79],[3,4,8,11,14,22,30,31,33,48,49,51,57,58,63,64,67,68,74,76],[2,3,7,8,16,23,27,31,32,33,35,43,46,50,51,57,59,66,69,71],[1,2,5,7,20,21,23,27,39,42,45,49,54,58,63,67,70,71,72,74],[6,16,22,23,25,30,32,36,41,44,45,51,55,65,66,67,71,74,75,76],[9,10,14,16,19,23,25,27,33,34,37,39,42,50,51,58,67,69,72,75],[2,4,7,9,17,22,23,24,26,29,33,38,43,50,55,56,71,77,78,79],[2,5,6,7,9,23,25,26,34,37,45,46,50,53,54,57,65,72,73,78],[1,3,26,27,32,33,38,39,40,41,44,49,50,53,66,68,71,75,77,79],[2,3,4,6,8,10,13,17,19,20,26,34,36,48,51,54,57,62,70,76],[7,10,19,30,32,36,46,47,48,51,53,54,57,64,66,67,69,71,73,76],[6,9,15,18,19,23,26,30,34,38,46,49,55,57,60,70,71,72,77,80],[1,8,9,11,12,15,22,28,31,38,39,40,44,57,59,63,64,71,74,79],[2,3,4,5,7,12,32,42,44,49,50,54,56,62,63,69,71,75,76,77],[6,20,26,30,32,35,38,39,54,56,57,59,60,61,62,67,71,72,75,76],[2,5,6,7,9,16,30,32,40,48,56,57,58,59,60,69,70,72,74,80],[6,7,9,18,20,35,36,45,46,48,51,52,53,56,60,66,68,77,79,80],[3,7,15,21,27,28,38,44,48,62,63,64,68,70,72,73,74,75,77,79],[9,12,13,14,16,21,22,27,29,31,32,44,49,50,52,53,62,65,72,77],[2,4,6,10,22,24,26,27,29,36,37,43,48,50,55,56,58,59,64,76],[13,14,17,18,19,27,29,31,37,41,43,49,53,56,59,61,65,67,68,79],[3,8,10,16,17,18,19,25,28,29,33,35,41,43,59,60,63,66,73,75],[4,9,12,14,18,21,22,23,24,26,29,30,41,53,58,62,69,71,72,73]]# 统计每个号码出现的次数,选择排名前35的号码all_red_balls = [ball for data in red_balls_history for ball in data]frequency_counts = Counter(all_red_balls)top_numbers = [number for number, _ in frequency_counts.most_common(35)]new_groups = []for _ in range(10): new_group = random.sample(top_numbers, 5) new_groups.append(new_group)print("快乐8热门号码随机:")for i, group in enumerate(new_groups, 1): print(f"组合 {i}: {group}") # 计算经常出现的两两组合top_combinations = Counter()for data in red_balls_history: for combination in combinations(data, 2): if all(num in top_numbers for num in combination): top_combinations[tuple(sorted(combination))] += 1# 选择出现次数最多的组合作为新的号码new_numbers = [list(combination) for combination, _ in top_combinations.most_common(6)]print("快乐8高频号码:", top_numbers)print("\n快乐8近期两码组合同出排行:")for combination, count in top_combinations.most_common(16): print(f"{combination} 出现 {count} 次")

今天,我特地利用中午的时间,给大家演示一下使用方法。

首先,我们复制最新一期的快乐8数据,[7,16,22,27,28,34,37,38,39,40,45,46,51,57,63,64,65,73,77,80],

copy到我们的统计代码中。

接着,我们复制整个代码,到我们收藏的在线Python编辑器中,粘贴到编辑器里,点击运行就可以了。

复制代码到编辑器

代码默认是统计两码,可修改代码中的2,为3就是统计三码,改为5就是五码同出统计。

代码运行结果

一般的在线编辑器统计五码会白屏出错,可自己下载一个Python编辑器带电脑,在本机运行本代码。

0 阅读:72
评论列表