
HR随机面试题工具是一个面向面试官的一个应用工具,很多时候面试官在提问问题的时候突然卡主了,不知道面试什么,所以根据这个需求来创建的这款应用工具,使用的是腾讯云AI代码助手来生成的所有代码,使用方便,快捷,高效。
python语言的tk库来完成的GUI页面设计,通过代码来完成具体的业务逻辑。
连续性的提问。
1、创建页面
2、添加基础功能获取一个题库(excel格式)
3、读取excel文件信息到程序中并展示
4、将读取到的内容存储到一个数据列表中
5、添加显示随机问题数量输入栏,以及提问按钮,点击后显示在一个多行文本框中
6、添加一个是否显示参考答案的按钮
系统:win11系统 工具:VSCode开发工具 插件:安装腾讯云AI代码助手插件
1、通过IO流读取Excel文件并解析
2、通过输入的随机数量获取题目的问题以及答案
3、控制是否显示问题答案
完整的助力于开发的整个生命周期,包括初始页面到数据展示以及操作,最后进行打包exe文件。
1、选择问题的Excel文件
2、输入要显示的问题数量
3、点击随机显示问题按钮
4、操作是否显示答案
import tkinter as tk # 导入tkinter模块
from tkinter import filedialog, messagebox
import pandas as pd
import random
# 全局变量
data_df = None
show_answer = True # 新增变量,用于跟踪是否显示答案
background_color = "#87CEEB" # 天蓝色的十六进制代码
def upload_and_read_excel():
# 打开文件选择对话框
file_path = filedialog.askopenfilename(filetypes=[("Excel files", "*.xlsx"), ("Excel files", "*.xls")])
if file_path:
try:
# 使用pandas读取Excel文件
df = pd.read_excel(file_path)
# 检查是否包含预期的三列
if set(df.columns) == {'序号', '问题', '答案'}:
global data_df # 声明为全局变量以便在其他函数使用
data_df = df
messagebox.showinfo("成功", "文件读取成功!")
else:
messagebox.showerror("错误", "Excel文件必须包含'序号', '问题', '答案'三列。")
except Exception as e:
messagebox.showerror("错误", f"读取Excel文件时发生错误:{e}")
def toggle_answers():
global show_answer
show_answer = not show_answer
update_display()
def update_display():
try:
num = int(entry_num.get())
if num > len(data_df) or num <= 0:
messagebox.showerror("错误", "请输入合理的题目数量!")
return
random_indices = random.sample(range(len(data_df)), num)
selected_questions = data_df.iloc[random_indices]
display_text.delete('1.0', tk.END)
for index, row in selected_questions.iterrows():
question = f"问题:{row['问题']}"
answer = f"答案:{row['答案']}" if show_answer else ""
display_text.insert(tk.END, question+ "\n" + answer+ "\n" + '-'*50 + '\n')
except ValueError:
messagebox.showerror("错误", "请输入有效的数字!")
def generate_questions():
update_display()
def main():
global entry_num, display_text # 声明全局变量
# 创建主窗口并设置背景颜色
root = tk.Tk()
root.configure(background=background_color)
# 设置窗口标题
root.title("HR随机面试题工具")
# 设置窗口大小为800x600像素
root.geometry("800x600")
# 可选:设置窗口是否可以调整大小
root.resizable(False, False) # 禁止调整大小
# 添加一个标签并设置背景颜色
label = tk.Label(root, text="欢迎使用HR随机面试题工具", font=("Arial", 16), bg=background_color)
label.pack(pady=20) # 使用pack布局,并添加垂直间距
# 添加一个输入框用于输入数量,设置框架背景颜色
frame_input = tk.Frame(root, bg=background_color)
frame_input.pack(pady=10)
label_num = tk.Label(frame_input, text="请输入要生成的题目数量:", bg=background_color)
label_num.pack(side=tk.LEFT)
entry_num = tk.Entry(frame_input)
entry_num.pack(side=tk.LEFT)
# 添加按钮并设置背景颜色
button_generate = tk.Button(root, text="生成面试题", command=generate_questions, bg=background_color)
button_generate.pack(pady=10) # 使用pack布局,并添加垂直间距
button_upload = tk.Button(root, text="上传Excel文件", command=upload_and_read_excel, bg=background_color)
button_upload.pack(pady=10) # 使用pack布局,并添加垂直间距
button_toggle = tk.Button(root, text="隐藏答案" if show_answer else "显示答案", command=toggle_answers, bg=background_color)
button_toggle.pack(pady=5) # 使用pack布局,并添加垂直间距
# 添加一个文本框用于显示结果,并设置背景颜色
display_text = tk.Text(root, height=20, width=100, wrap=tk.WORD, bg=background_color)
display_text.pack(pady=20, fill=tk.BOTH, expand=True)
# 进入主循环,等待用户操作
root.mainloop()
if __name__ == "__main__":
main()具体实验室视频地址:https://live.csdn.net/v/442412

1. 提高效率:
自动化生成面试题目,减少手动整理的时间成本。 快速响应面试需求,灵活调整题目内容和数量。
2. 标准化评估:
确保面试过程的公平性和一致性,提高评估的准确性和可靠性。 提供标准化的答案参考,便于统一评分标准。
3. 增强用户体验:
直观的用户界面和简洁的操作流程,降低使用门槛。 提供即时反馈和错误提示,提升用户体验和满意度。
4. 数据驱动决策:
可以结合实际使用数据,分析题目难度和候选人表现,优化题库和评估标准。 为人力资源管理提供数据支持,助力科学决策。
5. 可扩展性与定制化:
支持自定义题库和题目类型,满足不同公司和岗位的特定需求。 未来可以进一步扩展功能,如增加在线协作、数据分析等功能,提升工具的综合价值。