好友
阅读权限25
听众
最后登录1970-1-1
|
风子是我
发表于 2025-7-23 22:55
本帖最后由 风子是我 于 2025-7-25 16:00 编辑
考试院投档结果出来了,各分数线也出来了,可以提供下载,但是考生登录查询不到录取数据,是因为有个时间差,或者院校没来得及上传数据,而考生急于知道结果,按老办法是按志愿顺序一个一个地核对排查,也是能知道结果的,只是效率太低;
今年我为几十个考生填报志愿了,为了方便他们第一时间知道录取结果,编写了这个小工具。也是为了明年大规模应用而准备。
小工具分为两个版本,python版和html版,都有源码,其中python版提供打包后的exe文件。
软件使用界面截图:
使用注意事项
确保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)
|
免费评分
-
查看全部评分
|