Python可视化界面小工具,可自定义历史期数,历史双色球数据,打印结果、写入excel表格、并进行简单的结果分析;

1、工具效果图如下图所示:

2、生成Excel表格数据格式如下图所示:

3、完整代码如下:

# !/usr/bin/python
# -*- coding: utf-8 -*-import os
import re
import requests
import json
import sys
import time
sys.path.append('../')
from tkinter import ttk
from tkinter.ttk import *
from tkinter import *
import tkinter.font as tf
import xlwt
try:import io, syssys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')sys.stdout._CHUNK_SIZE = 1
except:pass# 获取实时时间
def now_time():now = int(time.time())  # 这是时间戳# 转换为其他日期格式,如:"%Y-%m-%d %H:%M:%S"timeArray = time.localtime(now)# otherStyleTime = time.strftime("%Y/%m/%d %H:%M:%S", timeArray)today = time.strftime("%m%d%H%M%S", timeArray)return todaydef get_history_lotto(pageSize):"""爬取号码数据"""url = 'http://www.cwl.gov.cn/cwl_admin/front/cwlkj/search/kjxx/findDrawNotice?name=ssq&pageNo=1&pageSize={}&systemType=PC'.format(pageSize)headers = {'Host': 'www.cwl.gov.cn','Referer': 'http://www.cwl.gov.cn/c/2023/01/17/527544.shtml','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36'}response = requests.get(url=url, headers=headers)result = json.loads(response.text).get("result")res_dict = {}for res in result:res_dict[res["code"]] = res["red"] +"," + res["blue"]# print(res_dict)return res_dictdef cp_res(pageSize):res_dict = get_history_lotto(pageSize)today = now_time()# Excel路径excel_path = "D://res_dict_{}.xls".format(today)# 创建新的工作簿wb = xlwt.Workbook()#创建新的工作表she = wb.add_sheet("彩票")al = xlwt.Alignment()# 设置水平居中al.horz = 0x02# 设置垂直居中al.vert = 0x01# 添加边框borders = xlwt.Borders()# DASHED:虚线  NO_LINE:没有  THIN:实线borders.left = xlwt.Borders.THINborders.right = xlwt.Borders.THINborders.top = xlwt.Borders.THINborders.bottom = xlwt.Borders.THINborders.left_colour = 0x40borders.right_colour = 0x40borders.top_colour = 0x40borders.bottom_colour = 0x40#设置背景颜色pattern = xlwt.Pattern()pattern.pattern = xlwt.Pattern.SOLID_PATTERN#背景颜色pattern.pattern_fore_colour = 27# 黑色字体并居中# 初始化样式style0 = xlwt.XFStyle()style0.alignment = al# 为样式创建字体font0 = xlwt.Font()# 黑体font0.bold = True# 0:黑色;2:红色;12:蓝色font0.colour_index = 0# 设定样式style0.font = font0style0.borders = bordersstyle0.pattern = pattern# 红色加粗字体并居中style01 = xlwt.XFStyle()style01.alignment = alfont01 = xlwt.Font()font01.bold = Truefont01.colour_index = 2style01.font = font01style01.borders = bordersstyle01.pattern = pattern# 蓝色加粗字体并居中style02 = xlwt.XFStyle()style02.alignment = alfont02 = xlwt.Font()font02.bold = Truefont02.colour_index = 12style02.font = font02style02.borders = bordersstyle02.pattern = pattern# 蓝色非加粗字体并居中style = xlwt.XFStyle()style.alignment = alfont = xlwt.Font()# font.bold = Truefont.colour_index = 12style.font = fontstyle.borders = borders# 红色非加粗字体并居中# 设置字体在单元格的位置alignment = xlwt.Alignment()# 水平方向alignment.horz = xlwt.Alignment.HORZ_CENTER# 竖直方向alignment.vert = xlwt.Alignment.VERT_CENTERstyle1 = xlwt.XFStyle()style1.alignment = alignmentfont1 = xlwt.Font()# font1.bold = Truefont1.colour_index = 2style1.font = font1style1.borders = borders# 第一行第一列写入数据she.write(0, 0, "期数\\彩票", style0)# 写入红色球数据for i in range(1,34):she.write(0, i, i, style01)# 写入蓝色球数据for j in range(1,17):she.write(0, j+33, j, style02)# 设置列宽for k in range(1,50):she.col(k).width = 256 * 3i=1for key,value in res_dict.items():#将字典中的键放在第0列she.write(i, 0, key, style0)values = value.split(",")hong_list = values[0:-1]lan = int(values[-1])for hong in hong_list:hong = int(hong)#写入数据she.write(i, hong, hong, style1)she.write(i,lan+33,lan, style)i += 1wb.save(excel_path)return excel_pathdef print_res(pageSize):res_dict = get_history_lotto(pageSize)str_res = ""for key, value in res_dict.items():hong = " ".join(value.split(","))str_res += "第"+ key + "期:" + hong + "\n"return str_resdef analysis_res(pageSize):res_dict = get_history_lotto(pageSize)# str_res = ""hong_list = []lan_list = []for key, value in res_dict.items():hong_list.extend(value.split(",")[:-1])hong = ",".join(value.split(",")[:-1])lan = value.split(",")[-1]lan_list.append(lan)# str_res += "第"+ key + "期:" +"红色球:" + hong + ",蓝色球:" + lan + "\n"hong_result = "近{}期红色球解析结果(倒序):\n".format(pageSize)lan_result = "近{}期蓝色球解析结果(倒序):\n".format(pageSize)hong_dict = {}lan_dict = {}for i in range(1,34):i = str(i).zfill(2)hong_dict[i] = hong_list.count(i)for i in range(1,17):i = str(i).zfill(2)lan_dict[i] = lan_list.count(i)# 红色球&蓝色球根据出现次数进行倒序hong_dict = sorted(hong_dict.items(), key=lambda x:x[1], reverse=True)lan_dict = sorted(lan_dict.items(), key=lambda x:x[1], reverse=True)# print(hong_dict, lan_dict)for k, v in hong_dict:hong_result += k + " 出现次数:" + str(v) + "\n"for k, v in lan_dict:lan_result += k + " 出现次数:" + str(v) + "\n"return hong_result + lan_resultdef visualization():# 创建窗口win = Tk()win.title("福彩双色球工具")# win.iconbitmap('*.ico')win.geometry('580x560')# win.resizable(0, 0)# 添加标签控件def test():try:int(label1.get())print("正确!")return Trueexcept:print("错误!")label1.delete(0, "end")return Falsev = StringVar()#fleur:十字箭头 heart:心形 man:男人 plus:十字架 mouse:鼠标label1 = Entry(win, width=22, bg='yellow', bd=3, cursor='heart', textvariable=v, validate="focusout", validatecommand=test)label1.grid(row=0, column=0,sticky='NW', padx=78, pady=5)Label(win, text="历史期数(期):").grid(row=0, sticky="W")# txt.set("在这里输入正整数...")# label1.insert(0, 50)Label(win, text="注:只可填入数字,填10表示前10期数据,不填或填错默认为50").grid(row=0, padx=238, pady=5)# 生成Excel文件按钮绑定执行事件,结果插入Text文本def save_excel():text.delete("1.0", "end")try:int(label1.get())res = cp_res(label1.get())except:res = cp_res("50")text.insert('insert', "结果路径:" +res + "\n")# 打印结果按钮绑定回调函数def print_result():text.delete("1.0", "end")try:int(label1.get())res = print_res(label1.get())except:res = print_res("50")font1 = tf.Font(family='微软雅黑',size=10)text.insert('insert', res + "\n")for i in range(1, res.count("第") + 1):text.tag_add("tag1","{}.1".format(i),"{}.8".format(i))text.tag_add("tag2","{}.10".format(i),"{}.28".format(i))text.tag_add("tag3","{}.28".format(i),"{}.30".format(i))text.tag_config("tag1",foreground="green")text.tag_config("tag2",foreground="red")text.tag_config("tag3",foreground="blue")text.config(font=font1)# 结果解析按钮绑定回调函数def analysis_result():text.delete("1.0", "end")try:int(label1.get())res = analysis_res(label1.get())except:res = analysis_res("50")frist = len(res.split("\n")[0])font1 = tf.Font(family='微软雅黑',size=10)text.insert('insert', res + "\n")text.tag_add("tag1", "1.0", "1.{}".format(frist))text.tag_add("tag2", "35.0", "35.{}".format(frist))for i in range(2, 35):text.tag_add("tag3","{}.0".format(i),"{}.2".format(i))text.tag_add("tag4","{}.8".format(i),"{}.14".format(i))for i in range(36, 52):text.tag_add("tag5","{}.0".format(i),"{}.2".format(i))text.tag_add("tag6","{}.8".format(i),"{}.14".format(i))text.tag_config("tag1",foreground="red")text.tag_config("tag2",foreground="blue")text.tag_config("tag3",foreground="red")text.tag_config("tag4",foreground="green")text.tag_config("tag5",foreground="blue")text.tag_config("tag6",foreground="green")text.config(font=font1)# 清除内容按钮绑定回调函数def clearBox():text.delete("1.0", "end")Button(win, text="打印结果", width=8, command=print_result).grid(row=1, column=0, sticky="W", padx=5, pady=5)Button(win, text="生成Excel文件", width=12, command=save_excel).grid(row=1, column=0, sticky="W", padx=80, pady=5)Button(win, text="结果解析", command=analysis_result).grid(row=1, column=0, sticky="W", padx=186, pady=5)Button(win, text="清空内容", command=clearBox).grid(row=1, column=0, sticky="W", padx=256, pady=5)Label(win, text="注:生成Excel文件更易观察").grid(row=1, padx=318, pady=5)# 新建文本框text = Text(win)# 布局text.grid(row=2, column=0, sticky="W", padx=5, pady=18)win.mainloop()if __name__ == '__main__':visualization()

优化封装代码:

# !/usr/bin/python
# -*- coding: utf-8 -*-import os
import re
import requests
import json
import sys
import time
sys.path.append('../')
from tkinter import ttk
from tkinter.ttk import *
from tkinter import *
from tkinter.messagebox import *
import tkinter.font as tf
from shuangseqiu import *
from daletou import *
try:import io, syssys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')sys.stdout._CHUNK_SIZE = 1
except:passclass ApplicationUi(Frame):#实现界面生成功能。def __init__(self, master=None):Frame.__init__(self, master)self.master.title('彩票工具')self.master.geometry('580x580')self.createWidgets()def visualization_ssq(self):self.TabStrip1__Tab1 = Frame(self.TabStrip1)self.TabStrip1__Lbl = Label(self.TabStrip1__Tab1, text='双色球工具')self.TabStrip1__Lbl.place(relx=0.1,rely=0.5)# 添加标签控件self.TabStrip1__v = StringVar()#fleur:十字箭头 heart:心形 man:男人 plus:十字架 mouse:鼠标Label(self.TabStrip1__Tab1, text="历史期数(期):").place(x = 5, y = 8)# 创建下拉菜单, 使用 place() 来控制控件的位置self.TabStrip1_cbox = ttk.Combobox(self.TabStrip1__Tab1)self.TabStrip1_cbox.place(x = 85, y = 8)# 设置下拉菜单中的值 get_log_path()self.TabStrip1_cbox['value'] = ["10","20","50","100","200"]self.TabStrip1_cbox["width"] = 15#通过 current() 设置下拉菜单选项的默认值try:self.TabStrip1_cbox.current(3)except:pass# txt.set("在这里输入正整数...")# self.TabStrip1_cbox.insert(0, 50)Label(self.TabStrip1__Tab1, text="注:可自定义填入数字").place(x = 250, y = 8)# 生成Excel文件按钮绑定执行事件,结果插入Text文本def save_excel():self.text.delete("1.0", "end")try:int(self.TabStrip1_cbox.get())res = cp_res(self.TabStrip1_cbox.get())except:res = cp_res("50")self.text.insert('insert', "双色球结果路径:" +res + "\n")# 打印结果按钮绑定回调函数def print_result():self.text.delete("1.0", "end")try:int(self.TabStrip1_cbox.get())res = print_res(self.TabStrip1_cbox.get())except:res = print_res("50")font1 = tf.Font(family='微软雅黑',size=10)self.text.insert('insert', res + "\n")for i in range(1, res.count("第") + 1):self.text.tag_add("tag1","{}.1".format(i),"{}.8".format(i))self.text.tag_add("tag2","{}.10".format(i),"{}.28".format(i))self.text.tag_add("tag3","{}.28".format(i),"{}.30".format(i))self.text.tag_config("tag1",foreground="green")self.text.tag_config("tag2",foreground="red")self.text.tag_config("tag3",foreground="blue")self.text.config(font=font1)# 结果解析按钮绑定回调函数def analysis_result():self.text.delete("1.0", "end")try:int(self.TabStrip1_cbox.get())res = analysis_res(self.TabStrip1_cbox.get())except:res = analysis_res("50")frist = len(res.split("\n")[0])font1 = tf.Font(family='微软雅黑',size=10)self.text.insert('insert', res + "\n")self.text.tag_add("tag1", "1.0", "1.{}".format(frist))self.text.tag_add("tag2", "35.0", "35.{}".format(frist))for i in range(2, 35):self.text.tag_add("tag3","{}.0".format(i),"{}.2".format(i))self.text.tag_add("tag4","{}.8".format(i),"{}.14".format(i))for i in range(36, 52):self.text.tag_add("tag5","{}.0".format(i),"{}.2".format(i))self.text.tag_add("tag6","{}.8".format(i),"{}.14".format(i))self.text.tag_config("tag1",foreground="red")self.text.tag_config("tag2",foreground="blue")self.text.tag_config("tag3",foreground="red")self.text.tag_config("tag4",foreground="green")self.text.tag_config("tag5",foreground="blue")self.text.tag_config("tag6",foreground="green")self.text.config(font=font1)# 清除内容按钮绑定回调函数def clearBox():self.text.delete("1.0", "end")Button(self.TabStrip1__Tab1, text="打印结果", width=8, command=print_result).place(x=5, y=35)Button(self.TabStrip1__Tab1, text="生成Excel文件", width=12, command=save_excel).place(x=80, y=35)Button(self.TabStrip1__Tab1, text="结果解析", command=analysis_result).place(x=186, y=35)Button(self.TabStrip1__Tab1, text="清空内容", command=clearBox).place(x=256, y=35)Label(self.TabStrip1__Tab1, text="注:生成Excel文件更易观察").place(x=320, y=38)# 新建文本框self.text = Text(self.TabStrip1__Tab1, width=500)# 布局self.text.grid(pady=70)self.TabStrip1.add(self.TabStrip1__Tab1, text='双色球工具')def visualization_dlt(self):self.TabStrip2__Tab1 = Frame(self.TabStrip1)self.TabStrip2__Lbl = Label(self.TabStrip2__Tab1, text='大乐透工具')self.TabStrip2__Lbl.place(relx=0.1,rely=0.5)# 添加标签控件self.TabStrip2__v = StringVar()#fleur:十字箭头 heart:心形 man:男人 plus:十字架 mouse:鼠标Label(self.TabStrip2__Tab1, text="历史期数(期):").place(x = 5, y = 8)# 创建下拉菜单, 使用 place() 来控制控件的位置self.TabStrip2_cbox = ttk.Combobox(self.TabStrip2__Tab1)self.TabStrip2_cbox.place(x = 85, y = 8)# 设置下拉菜单中的值 get_log_path()self.TabStrip2_cbox['value'] = ["10","20","50","100","200"]self.TabStrip2_cbox["width"] = 15#通过 current() 设置下拉菜单选项的默认值try:self.TabStrip2_cbox.current(3)except:pass# txt.set("在这里输入正整数...")# self.TabStrip2_cbox.insert(0, 50)Label(self.TabStrip2__Tab1, text="注:可自定义填入数字").place(x = 250, y = 8)# 生成Excel文件按钮绑定执行事件,结果插入Text文本def save_excel():self.text2.delete("1.0", "end")try:res = cp_dlres(self.TabStrip2_cbox.get())except:res = cp_dlres("50")self.text2.insert('insert', "大乐透结果路径:" +res + "\n")self.text2.insert("-----------------------------------------")# 打印结果按钮绑定回调函数def print_result():self.text2.delete("1.0", "end")try:int(self.TabStrip2_cbox.get())res = print_dlres(self.TabStrip2_cbox.get())except:res = print_dlres("50")font1 = tf.Font(family='微软雅黑',size=10)self.text2.insert('insert', res + "\n")for i in range(1, res.count("第") + 1):# 第23018期:04 08 17 26 30 03 11self.text2.tag_add("tag1","{}.1".format(i),"{}.6".format(i))self.text2.tag_add("tag2","{}.8".format(i),"{}.22".format(i))self.text2.tag_add("tag3","{}.23".format(i),"{}.28".format(i))self.text2.tag_config("tag1",foreground="green")self.text2.tag_config("tag2",foreground="red")self.text2.tag_config("tag3",foreground="blue")self.text2.config(font=font1)# 结果解析按钮绑定回调函数def analysis_result():self.text2.delete("1.0", "end")try:int(self.TabStrip2_cbox.get())res = analysis_dlres(self.TabStrip2_cbox.get())except:res = analysis_dlres("50")frist = len(res.split("\n")[0])font1 = tf.Font(family='微软雅黑',size=10)self.text2.insert('insert', res + "\n")self.text2.tag_add("tag1", "1.0", "1.{}".format(frist))self.text2.tag_add("tag2", "37.0", "37.{}".format(frist))for i in range(2, 37):self.text2.tag_add("tag3","{}.0".format(i),"{}.2".format(i))self.text2.tag_add("tag4","{}.8".format(i),"{}.14".format(i))for i in range(38, 52):self.text2.tag_add("tag5","{}.0".format(i),"{}.2".format(i))self.text2.tag_add("tag6","{}.8".format(i),"{}.14".format(i))self.text2.tag_config("tag1",foreground="red")self.text2.tag_config("tag2",foreground="blue")self.text2.tag_config("tag3",foreground="red")self.text2.tag_config("tag4",foreground="green")self.text2.tag_config("tag5",foreground="blue")self.text2.tag_config("tag6",foreground="green")self.text2.config(font=font1)# 清除内容按钮绑定回调函数def clearBox():self.text2.delete("1.0", "end")Button(self.TabStrip2__Tab1, text="打印结果", width=8, command=print_result).place(x=5, y=35)Button(self.TabStrip2__Tab1, text="生成Excel文件", width=12, command=save_excel).place(x=80, y=35)Button(self.TabStrip2__Tab1, text="结果解析", command=analysis_result).place(x=186, y=35)Button(self.TabStrip2__Tab1, text="清空内容", command=clearBox).place(x=256, y=35)Label(self.TabStrip2__Tab1, text="注:生成Excel文件更易观察").place(x=320, y=38)# 新建文本框self.text2 = Text(self.TabStrip2__Tab1, width=500)# 布局self.text2.grid(pady=70)self.TabStrip1.add(self.TabStrip2__Tab1, text='大乐透工具')def createWidgets(self):self.top = self.winfo_toplevel()self.style = Style()self.TabStrip1 = Notebook(self.top)self.TabStrip1.place(relx=0.009, rely=0.009, relwidth=0.991, relheight=0.991)self.visualization_ssq()self.visualization_dlt()if __name__ == '__main__':top = Tk()ApplicationUi(top).mainloop()

大乐透代码:

# !/usr/bin/python
# -*- coding: utf-8 -*-import os
import re
import requests
import json
import sys
import time
sys.path.append('../')
import xlwt
try:import io, syssys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')sys.stdout._CHUNK_SIZE = 1
except:pass# 获取实时时间
def now_time():now = int(time.time())  # 这是时间戳# 转换为其他日期格式,如:"%Y-%m-%d %H:%M:%S"timeArray = time.localtime(now)# otherStyleTime = time.strftime("%Y/%m/%d %H:%M:%S", timeArray)today = time.strftime("%m%d%H%M%S", timeArray)return todaydef get_history_dllotto(pageSize):"""爬取号码数据 35选5 + 12选2"""url = 'https://webapi.sporttery.cn/gateway/lottery/getHistoryPageListV1.qry?gameNo=85&provinceId=0&pageSize={}'.format(pageSize)headers = {'Host': 'webapi.sporttery.cn','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36'}response = requests.get(url=url, headers=headers)result_list = json.loads(response.text).get("value").get("list")res_dict = {}for res in result_list:res_dict[res["lotteryDrawNum"]] = res["lotteryDrawResult"]return res_dictdef cp_dlres(pageSize):res_dict = get_history_dllotto(pageSize)today = now_time()# Excel路径excel_path = "D://dlt_res_dict_{}.xls".format(today)# 创建新的工作簿wb = xlwt.Workbook()#创建新的工作表she = wb.add_sheet("大乐透")al = xlwt.Alignment()# 设置水平居中al.horz = 0x02# 设置垂直居中al.vert = 0x01# 添加边框borders = xlwt.Borders()# DASHED:虚线  NO_LINE:没有  THIN:实线borders.left = xlwt.Borders.THINborders.right = xlwt.Borders.THINborders.top = xlwt.Borders.THINborders.bottom = xlwt.Borders.THINborders.left_colour = 0x40borders.right_colour = 0x40borders.top_colour = 0x40borders.bottom_colour = 0x40#设置背景颜色pattern = xlwt.Pattern()pattern.pattern = xlwt.Pattern.SOLID_PATTERN#背景颜色pattern.pattern_fore_colour = 27# 黑色字体并居中# 初始化样式style0 = xlwt.XFStyle()style0.alignment = al# 为样式创建字体font0 = xlwt.Font()# 黑体font0.bold = True# 0:黑色;2:红色;12:蓝色font0.colour_index = 0# 设定样式style0.font = font0style0.borders = bordersstyle0.pattern = pattern# 红色加粗字体并居中style01 = xlwt.XFStyle()style01.alignment = alfont01 = xlwt.Font()font01.bold = Truefont01.colour_index = 2style01.font = font01style01.borders = bordersstyle01.pattern = pattern# 蓝色加粗字体并居中style02 = xlwt.XFStyle()style02.alignment = alfont02 = xlwt.Font()font02.bold = Truefont02.colour_index = 12style02.font = font02style02.borders = bordersstyle02.pattern = pattern# 蓝色非加粗字体并居中style = xlwt.XFStyle()style.alignment = alfont = xlwt.Font()# font.bold = Truefont.colour_index = 12style.font = fontstyle.borders = borders# 红色非加粗字体并居中# 设置字体在单元格的位置alignment = xlwt.Alignment()# 水平方向alignment.horz = xlwt.Alignment.HORZ_CENTER# 竖直方向alignment.vert = xlwt.Alignment.VERT_CENTERstyle1 = xlwt.XFStyle()style1.alignment = alignmentfont1 = xlwt.Font()# font1.bold = Truefont1.colour_index = 2style1.font = font1style1.borders = borders# 第一行第一列写入数据she.write(0, 0, "期数\\彩票", style0)# 写入前区红球数据for i in range(1,36):she.write(0, i, i, style01)# 写入后区蓝球数据for j in range(1,13):she.write(0, j+35, j, style02)# 设置列宽for k in range(1,49):she.col(k).width = 256 * 3i=1for key,value in res_dict.items():#将字典中的键放在第0列she.write(i, 0, key, style0)values = value.split(" ")hong_list = values[0:-2]lan_list = values[-2:]for hong in hong_list:hong = int(hong)#写入数据she.write(i, hong, hong, style1)for lan in lan_list:lan = int(lan)she.write(i, lan+35, lan, style)i += 1wb.save(excel_path)return excel_pathdef print_dlres(pageSize):res_dict = get_history_dllotto(pageSize)str_res = ""for key, value in res_dict.items():str_res += "第"+ key + "期:" + value + "\n"return str_resdef analysis_dlres(pageSize):res_dict = get_history_dllotto(pageSize)hong_list = []lan_list = []for key, value in res_dict.items():hong_list.extend(value.split(" ")[:-2])lan = value.split(" ")[-2:]lan_list.extend(lan)# str_res += "第"+ key + "期:" +"红色球:" + hong + ",蓝色球:" + lan + "\n"hong_result = "近{}期前区红球解析结果(倒序):\n".format(pageSize)lan_result = "近{}期后区蓝球解析结果(倒序):\n".format(pageSize)hong_dict = {}lan_dict = {}for i in range(1,36):i = str(i).zfill(2)hong_dict[i] = hong_list.count(i)for i in range(1,13):i = str(i).zfill(2)lan_dict[i] = lan_list.count(i)# 红色球&蓝色球根据出现次数进行倒序hong_dict = sorted(hong_dict.items(), key=lambda x:x[1], reverse=True)lan_dict = sorted(lan_dict.items(), key=lambda x:x[1], reverse=True)# print(hong_dict, lan_dict)for k, v in hong_dict:hong_result += k + " 出现次数:" + str(v) + "\n"for k, v in lan_dict:lan_result += k + " 出现次数:" + str(v) + "\n"return hong_result + lan_resultif __name__ == '__main__':cp_dlres(10)

历史数据双色球小工具相关推荐

  1. flash air 版 双色球小工具

    提供以下功能,专家预测.历史数据分析.机选号.智能缩水 主界面: 机选号界面: 历史数据分析界面: 智能缩水界面: 专家预测界面: 开奖查询界面,买了好几注的彩票,一个数字一个数字去比对,累啊,让电脑 ...

  2. matlab软件中GUI界面开发学习——双色球选择小工具

    matlab软件中GUI界面开发学习--双色球选择小工具 先上一张界面截图: 特别说明:只是最近对双色球比较感兴趣,所以找了一个实际的项目依据帮助我学习GUI工具,小工具的相关条件仅代表个人想法,选择 ...

  3. 用Python制作一个随机抽奖小工具

    最近在工作中面向社群玩家组织了一场活动,需要进行随机抽奖,参考之前小明大佬的案例,再结合自己的需求,做了一个简单的随机抽奖小工具. 今天我就来顺便介绍一下这个小工具的制作过程吧! 先看效果: 1. 核 ...

  4. 使用C#编写一个读取和判断股票实时成交数据的小工具

    使用vs2019预览版,.net4.5进行编写,定位为一个数据分析的小工具,对个股的每笔成交进行分析判断,目前想到的就这些功能,并且还存在很多问题,不断完善中. 本身不是专业写程序的,只是处于爱好在闲 ...

  5. 分享一个小工具:Excel表高速转换成JSON字符串

    在游戏项目中一般都须要由策划制作大量的游戏内容,当中非常大一部分是使用Excel表来制作的.于是程序就须要把Excel文件转换成程序方便读取的格式. 之前项目使用的Excel表导入工具都是通过Offi ...

  6. 代码整理工具_程序员软件:程序员有哪些常用又好用的编码小工具?

    最近,有很多朋友让我帮忙整理一下程序员有哪些常用又好用的编码小工具.今天,小编就整理一下哦,希望大家一起学习,一起进步! 1. Notepad++ Notepad++中文版是一款非常有特色的编辑器,是 ...

  7. python自动翻译小工具_Python实现翻译小工具

    一.背景 利用Requests模块获取有道词典web页面的post信息,BeautifulSoup来获取需要的内容,通过tkinter模块生成gui界面. 二.代码 git源码地址 Python实现翻 ...

  8. 实用c语言函数源码,C语言编写简单朗读小工具(有源码)

    原标题:C语言编写简单朗读小工具(有源码) 最近不少人在后台留言说学C都是面对枯燥的控制台程序,能不能体现一下C语言的实际用途,今天我们就理论结合实践一把:C语言结合VBS脚本编写一个简单的朗读小工具 ...

  9. 【青少年编程】黄羽恒:翻译小工具 -- 利用百度翻译

    「青少年编程竞赛交流群」已成立(适合6至18周岁的青少年),公众号后台回复[Scratch]或[Python],即可进入.如果加入了之前的社群不需要重复加入. 微信后台回复"资料下载&quo ...

最新文章

  1. 工厂方法模式与抽象工厂模式的区别
  2. 程序员创业前要做哪些准备?
  3. 数据分析的 8 种思维
  4. python abs()函数是什么意思?
  5. Java socket中关闭IO流后,发生什么事?(以关闭输出流为例)
  6. border,padding,margin盒模型理解
  7. flask基础之jinja2模板-语法定义
  8. Flink CDC 系列 - 实现 MySQL 数据实时写入 Apache Doris
  9. 帆软获取单元格值与赋值
  10. deepin安装NVIDIA显卡驱动
  11. StyleBook皮肤控件的使用
  12. 互联网大数据项目汇报计划书PPT模板
  13. java随机生成随机整数_java生成随机整数
  14. Java字节码魔法数字_Java的魔法:字节码
  15. re.sub 使用方法
  16. java中十六进制数_Java中的十六进制到整数
  17. WEB打印-网页打印功能(带分页、可多页打印)
  18. Jenkins 自动构建之日程表配置
  19. 【Python项目】你们还在冲会员看电影电视剧嘛?Python带你免费看电影电视剧资源 | 附源码
  20. Android Launcher桌面图标显示数字

热门文章

  1. 【笔记】DenseTNT:End-to-end Trajectory Prediction from Dense Goal Sets
  2. 运筹系列65:TSP问题的精确求解法概述
  3. 微信域名批量检测的实现原理
  4. CAD面积周长同步测量
  5. linux上的修图软件,修图只知道Photoshop?11款高逼格修图工具快来get!
  6. ubuntu16.04 添加或删除PPA源
  7. myrio与fpga编程_myRIO入门实验指导书
  8. html css 最佳实践,30个CSS最佳实践 | Soo Smart!
  9. UniApp 基础(快速上手)
  10. 电子劳动合同,为企业用工护航