吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4300|回复: 75
收起左侧

[Python 原创] 高考录取结果查询

[复制链接]
风子是我 发表于 2025-7-23 22:55
本帖最后由 风子是我 于 2025-7-25 16:00 编辑

考试院投档结果出来了,各分数线也出来了,可以提供下载,但是考生登录查询不到录取数据,是因为有个时间差,或者院校没来得及上传数据,而考生急于知道结果,按老办法是按志愿顺序一个一个地核对排查,也是能知道结果的,只是效率太低;
今年我为几十个考生填报志愿了,为了方便他们第一时间知道录取结果,编写了这个小工具。也是为了明年大规模应用而准备。
小工具分为两个版本,python版和html版,都有源码,其中python版提供打包后的exe文件。
软件使用界面截图:
微信图片_2025-07-23_225950_800.png
使用注意事项
确保Excel文件格式正确:
投档分数线表必须包含:学校代号、专业代号、分数线、位次等列
考生志愿表必须包含:序号、学校代码、专业代码等列
(注意上面的代码与代号)
先上python源码:
[Python] 纯文本查看 复制代码
import pandas as pd
import tkinter as tk
from tkinter import messagebox, filedialog

class AdmissionQueryApp:
    def __init__(self, root):
        self.root = root
        self.root.title("高考录取查询系统")
        self.root.geometry("500x520")
        
        # 初始化文件路径变量
        self.scores_file = ""
        self.choices_file = ""
        
        # 创建界面组件
        self.create_widgets()
    
    def create_widgets(self):
        # 标题
        tk.Label(self.root, text="高考录取查询系统", font=('微软雅黑', 16)).pack(pady=10)
        
        # 文件选择部分
        tk.Label(self.root, text="1. 选择投档分数线表:").pack(anchor='w', padx=20, pady=5)
        self.scores_frame = tk.Frame(self.root)
        self.scores_frame.pack(fill=tk.X, padx=20)
        self.scores_entry = tk.Entry(self.scores_frame, width=40)
        self.scores_entry.pack(side=tk.LEFT, padx=5)
        tk.Button(
            self.scores_frame, 
            text="浏览...", 
            command=lambda: self.select_file(self.scores_entry, "选择投档分数线表")
        ).pack(side=tk.LEFT)
        
        tk.Label(self.root, text="2. 选择考生志愿表:").pack(anchor='w', padx=20, pady=5)
        self.choices_frame = tk.Frame(self.root)
        self.choices_frame.pack(fill=tk.X, padx=20)
        self.choices_entry = tk.Entry(self.choices_frame, width=40)
        self.choices_entry.pack(side=tk.LEFT, padx=5)
        tk.Button(
            self.choices_frame, 
            text="浏览...", 
            command=lambda: self.select_file(self.choices_entry, "选择考生志愿表")
        ).pack(side=tk.LEFT)
        
        # 分数和位次输入
        tk.Label(self.root, text="3. 输入考生总分:").pack(anchor='w', padx=20, pady=5)
        self.score_entry = tk.Entry(self.root, width=20)
        self.score_entry.pack(anchor='w', padx=20)
        
        tk.Label(self.root, text="4. 输入考生位次:").pack(anchor='w', padx=20, pady=5)
        self.rank_entry = tk.Entry(self.root, width=20)
        self.rank_entry.pack(anchor='w', padx=20)
        
        # 查询按钮
        self.query_btn = tk.Button(
            self.root, 
            text="查询录取结果", 
            command=self.query_admission,
            bg="#4CAF50",
            fg="white",
            font=('微软雅黑', 12),
            padx=20,
            pady=5
        )
        self.query_btn.pack(pady=20)
        
        # 结果显示
        self.result_label = tk.Label(
            self.root, 
            text="请按步骤操作后查询", 
            font=('微软雅黑', 12), 
            wraplength=450,
            justify=tk.LEFT
        )
        self.result_label.pack(pady=20)
    
    def select_file(self, entry_widget, title):
        """选择文件并更新输入框"""
        file_path = filedialog.askopenfilename(
            title=title,
            filetypes=[("Excel文件", "*.xls *.xlsx"), ("所有文件", "*.*")]
        )
        if file_path:
            entry_widget.delete(0, tk.END)
            entry_widget.insert(0, file_path)
    
    def load_data(self):
        """加载Excel数据,支持.xls和.xlsx格式"""
        try:
            scores_path = self.scores_entry.get()
            choices_path = self.choices_entry.get()
            
            if not scores_path or not choices_path:
                messagebox.showwarning("警告", "请先选择投档分数线表和考生志愿表")
                return None, None
            
            # 自动检测文件格式并选择合适的引擎
            def read_excel_auto(path):
                if path.endswith('.xls'):
                    return pd.read_excel(path, engine='xlrd')
                else:
                    return pd.read_excel(path, engine='openpyxl')
            
            df_scores = read_excel_auto(scores_path)
            df_choices = read_excel_auto(choices_path).sort_values('序号')
            
            return df_scores, df_choices
            
        except Exception as e:
            messagebox.showerror("错误", 
                f"加载数据失败:\n{str(e)}\n\n"
                "可能原因:\n"
                "1. 文件不是有效的Excel文件\n"
                "2. 文件已被其他程序打开\n"
                "3. 文件已损坏\n\n"
                "解决方案:\n"
                "1. 确认文件能正常用Excel打开\n"
                "2. 关闭已打开的文件\n"
                "3. 尝试另存为新Excel文件")
            return None, None
    
    def query_admission(self):
        """查询录取结果"""
        try:
            total_score = float(self.score_entry.get())
            rank = int(self.rank_entry.get())
            
            df_scores, df_choices = self.load_data()
            if df_scores is None or df_choices is None:
                return
            
            # 检查必要列是否存在
            required_columns = {
                'df_scores': ['学校代号', '专业代号', '分数线', '位次'],
                'df_choices': ['序号', '学校代码', '专业代码']
            }
            
            for df_name, cols in required_columns.items():
                df = locals()[df_name]
                for col in cols:
                    if col not in df.columns:
                        messagebox.showerror("错误", f"{df_name}中缺少必要列: {col}")
                        return
            
            # 遍历考生志愿表
            for _, choice in df_choices.iterrows():
                match = df_scores[
                    (df_scores['学校代号'] == choice['学校代码']) & 
                    (df_scores['专业代号'] == choice['专业代码']) &
                    (df_scores['分数线'] <= total_score) &
                    (df_scores['位次'] >= rank)
                ]
                
                if not match.empty:
                    school = match.iloc[0]['学校名称']
                    major = match.iloc[0]['专业名称']
                    self.result_label.config(
                        text=f"录取院校: {school}\n录取专业: {major}",
                        fg="green"
                    )
                    return
            
            self.result_label.config(
                text="很遗憾,您未被任何志愿录取\n\n"
                     "可能原因:\n"
                     "1. 分数未达到要求\n"
                     "2. 位次不符合要求\n"
                     "3. 志愿填报顺序问题",
                fg="red"
            )
            
        except ValueError:
            messagebox.showerror("错误", "请输入有效的分数和位次(数字)")
        except Exception as e:
            messagebox.showerror("错误", f"查询出错: {str(e)}")

if __name__ == "__main__":
    # 检查必要库是否安装
    required = {'xlrd': '1.2.0', 'openpyxl': '3.0.0', 'pandas': '1.0.0'}
    missing = []
    for lib, ver in required.items():
        try:
            __import__(lib)
        except ImportError:
            missing.append(lib)
    
    if missing:
        print(f"缺少依赖库: {', '.join(missing)}")
        print("请运行以下命令安装:")
        print("pip install xlrd openpyxl pandas")
        input("按Enter键退出...")
    else:
        root = tk.Tk()
        app = AdmissionQueryApp(root)
        root.mainloop()



再来个html源码:
[HTML] 纯文本查看 复制代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>高考录取查询系统</title>
    <script src="https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js"></script>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            max-width: 600px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        h1 {
            text-align: center;
            color: #333;
        }
        .container {
            background-color: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }
        input[type="text"], input[type="number"] {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        .file-input {
            display: flex;
            align-items: center;
        }
        .file-input input {
            flex-grow: 1;
            margin-right: 10px;
        }
        button {
            background-color: #4CAF50;
            color: white;
            border: none;
            padding: 10px 20px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
            margin: 20px 0;
            cursor: pointer;
            border-radius: 4px;
            width: 100%;
            font-family: 'Microsoft YaHei', sans-serif;
        }
        button:hover {
            background-color: #45a049;
        }
        #result {
            padding: 15px;
            border-radius: 4px;
            margin-top: 20px;
            white-space: pre-wrap;
        }
        .success {
            background-color: #dff0d8;
            color: #3c763d;
            border: 1px solid #d6e9c6;
        }
        .error {
            background-color: #f2dede;
            color: #a94442;
            border: 1px solid #ebccd1;
        }
        .info {
            background-color: #f8f9fa;
            color: #333;
            border: 1px solid #ddd;
        }
        #loading {
            display: none;
            text-align: center;
            margin: 10px 0;
            color: #666;
        }
        .file-info {
            font-size: 12px;
            color: #666;
            margin-top: 5px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>高考录取查询系统</h1>
        
        <div class="form-group">
            <label for="scoresFile">1. 选择投档分数线表:</label>
            <div class="file-input">
                <input type="text" id="scoresFile" readonly>
                <button type="button">浏览...</button>
                <input type="file" id="scoresInput" style="display: none;" accept=".xls,.xlsx">
            </div>
            <div id="scoresInfo" class="file-info">未选择文件</div>
        </div>
        
        <div class="form-group">
            <label for="choicesFile">2. 选择考生志愿表:</label>
            <div class="file-input">
                <input type="text" id="choicesFile" readonly>
                <button type="button">浏览...</button>
                <input type="file" id="choicesInput" style="display: none;" accept=".xls,.xlsx">
            </div>
            <div id="choicesInfo" class="file-info">未选择文件</div>
        </div>
        
        <div class="form-group">
            <label for="score">3. 输入考生总分:</label>
            <input type="number" id="score" step="0.1" placeholder="请输入考生总分">
        </div>
        
        <div class="form-group">
            <label for="rank">4. 输入考生位次:</label>
            <input type="number" id="rank" placeholder="请输入考生位次">
        </div>
        
        <div id="loading">正在处理数据,请稍候...</div>
        
        <button>查询录取结果</button>
        
        <div id="result" class="info">请按步骤操作后查询</div>
    </div>

    <script>
        // 全局变量存储数据
        let scoresData = null;
        let choicesData = null;
        
        function handleFileSelect(event, type) {
            const file = event.target.files[0];
            const displayId = type + 'File';
            const infoId = type + 'Info';
            const display = document.getElementById(displayId);
            const info = document.getElementById(infoId);
            
            if (file) {
                display.value = file.name;
                info.textContent = "正在加载...";
                document.getElementById('loading').style.display = 'block';
                
                const reader = new FileReader();
                
                reader.onload = function(e) {
                    try {
                        const data = new Uint8Array(e.target.result);
                        const workbook = XLSX.read(data, {type: 'array'});
                        
                        // 获取第一个工作表
                        const firstSheet = workbook.Sheets[workbook.SheetNames[0]];
                        // 转换为JSON
                        const jsonData = XLSX.utils.sheet_to_json(firstSheet, {defval: null});
                        
                        if (type === 'scores') {
                            scoresData = jsonData;
                            info.textContent = `已加载 ${jsonData.length} 条数据`;
                        } else {
                            choicesData = jsonData;
                            info.textContent = `已加载 ${jsonData.length} 条数据`;
                        }
                        
                        document.getElementById('result').textContent = `${file.name} 加载成功`;
                        document.getElementById('result').className = "info";
                    } catch (error) {
                        console.error("文件解析错误:", error);
                        info.textContent = "加载失败";
                        document.getElementById('result').textContent = `文件加载失败: ${error.message}`;
                        document.getElementById('result').className = "error";
                        
                        if (type === 'scores') {
                            scoresData = null;
                        } else {
                            choicesData = null;
                        }
                    } finally {
                        document.getElementById('loading').style.display = 'none';
                    }
                };
                
                reader.onerror = function() {
                    info.textContent = "读取错误";
                    document.getElementById('result').textContent = "文件读取错误,请重试";
                    document.getElementById('result').className = "error";
                    document.getElementById('loading').style.display = 'none';
                    
                    if (type === 'scores') {
                        scoresData = null;
                    } else {
                        choicesData = null;
                    }
                };
                
                reader.readAsArrayBuffer(file);
            }
        }
        
        function queryAdmission() {
            const resultDiv = document.getElementById('result');
            resultDiv.className = "info";
            
            try {
                // 验证输入
                const totalScore = parseFloat(document.getElementById('score').value);
                const rank = parseInt(document.getElementById('rank').value);
                
                if (isNaN(totalScore) || isNaN(rank)) {
                    resultDiv.textContent = "请输入有效的分数和位次(数字)";
                    resultDiv.className = "error";
                    return;
                }
                
                if (!scoresData || !choicesData) {
                    resultDiv.textContent = "请先选择并成功加载投档分数线表和考生志愿表";
                    resultDiv.className = "error";
                    return;
                }
                
                // 检查必要列是否存在
                const requiredScoresColumns = ['学校代号', '专业代号', '分数线', '位次'];
                const requiredChoicesColumns = ['序号', '学校代码', '专业代码'];
                
                // 检查投档分数线表
                const missingScoresColumns = requiredScoresColumns.filter(col => 
                    !scoresData[0] || !(col in scoresData[0])
                );
                if (missingScoresColumns.length > 0) {
                    resultDiv.textContent = `投档分数线表中缺少必要列: ${missingScoresColumns.join(', ')}`;
                    resultDiv.className = "error";
                    return;
                }
                
                // 检查考生志愿表
                const missingChoicesColumns = requiredChoicesColumns.filter(col => 
                    !choicesData[0] || !(col in choicesData[0])
                );
                if (missingChoicesColumns.length > 0) {
                    resultDiv.textContent = `考生志愿表中缺少必要列: ${missingChoicesColumns.join(', ')}`;
                    resultDiv.className = "error";
                    return;
                }
                
                // 对志愿表按序号排序
                choicesData.sort((a, b) => (a['序号'] || 0) - (b['序号'] || 0));
                
                // 遍历考生志愿表
                for (const choice of choicesData) {
                    const schoolCode = choice['学校代码'];
                    const majorCode = choice['专业代码'];
                    
                    // 在投档分数线表中查找匹配的记录
                    const matches = scoresData.filter(item => 
                        item['学校代号'] == schoolCode && 
                        item['专业代号'] == majorCode &&
                        (item['分数线'] || Infinity) <= totalScore &&
                        (item['位次'] || 0) >= rank
                    );
                    
                    if (matches.length > 0) {
                        const school = matches[0]['学校名称'] || '未知学校';
                        const major = matches[0]['专业名称'] || '未知专业';
                        const lineScore = matches[0]['分数线'];
                        const lineRank = matches[0]['位次'];
                        
                        resultDiv.innerHTML = `
                            <strong>恭喜您已被录取!</strong><br><br>
                            录取院校: ${school}<br>
                            录取专业: ${major}<br><br>
                            该专业投档线: ${lineScore}分<br>
                            该专业最低位次: ${lineRank}
                        `;
                        resultDiv.className = "success";
                        return;
                    }
                }
                
                resultDiv.innerHTML = `
                    <strong>很遗憾,您未被任何志愿录取</strong><br><br>
                    可能原因:<br>
                    1. 分数未达到要求<br>
                    2. 位次不符合要求<br>
                    3. 志愿填报顺序问题
                `;
                resultDiv.className = "error";
                
            } catch (e) {
                resultDiv.textContent = `查询出错: ${e.message}`;
                resultDiv.className = "error";
                console.error(e);
            }
        }
    </script>
</body>
</html>


最后提供exe成品:
通过网盘分享的文件:录取结果查询.exe
链接: https://pan.baidu.com/s/1vxTG_nyJWL77C5iBV86ARw 提取码: 52pj

测试数据:浙江教育考试院的下载链接被删了,我上传一个,其他省份的下载后的数据可以参照一下我这个数据改一下格式,同时提供一个考生的真实的数据,文件名包含这位考生的成绩与位次号;
老头的亲戚总分537位次127707_志愿表.rar (16.08 KB, 下载次数: 27) 浙江省2025年普通高校招生普通类第一段平行投档分数线表.rar (838.18 KB, 下载次数: 42)




免费评分

参与人数 12威望 +1 吾爱币 +17 热心值 +10 收起 理由
kubai + 1 热心回复!
zehesen + 1 用心讨论,共获提升!
苏紫方璇 + 1 + 10 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
banqiaoxu + 1 谢谢@Thanks!
POJIE20220721 + 1 我很赞同!
Bananan + 1 这个是个好东西,谢谢分享
Ss18910053906 + 1 谢谢@Thanks!
zweni + 1 + 1 热心回复!
3y3s + 1 + 1 我很赞同!
wwmusic + 1 + 1 我很赞同!
top777 + 1 + 1 谢谢@Thanks!
dhwl9899 + 1 + 1 谢谢@Thanks!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| 风子是我 发表于 2025-7-24 07:40
kingbeast 发表于 2025-7-24 01:31
谢谢成品,但是院校代码这些不好找啊

考试院下载啊,其它省我不知道,浙江省下载来的就可以用,只把第一行的标题删掉就行了。不用自己整理。
wwmusic 发表于 2025-7-24 08:31
yeeeKong 发表于 2025-7-23 23:33
SmFishGuru 发表于 2025-7-24 00:02
大佬666,真的很方便。
grrr_zhao 发表于 2025-7-24 00:25
本帖最后由 grrr_zhao 于 2025-7-24 00:28 编辑

感谢大佬,支持原创。52PJ。
zszq66 发表于 2025-7-24 00:32
非常感谢分享谢谢
xwlsjs 发表于 2025-7-24 00:36
不错不错,这小工具真应景
腐儒 发表于 2025-7-24 00:43
大佬牛啊!!!这个真得点个赞
wanderfor 发表于 2025-7-24 00:43
特别感谢老大万岁
失意 发表于 2025-7-24 00:51
能否搞一个中考的?
开心长寿果 发表于 2025-7-24 01:00
全国通用都能查吗
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - 52pojie.cn ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2026-5-17 04:57

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表