关于网站建设与发布的书籍,saas平台是干嘛的,网站优化师负责干什么,kesion系统做网站教程一、学生信息管理系统 本文使用Python语言开发了一个学生信息管理系统#xff0c;该系统可以帮助教师快速录入学生的信息#xff0c;并且对学生的信息进行基本的增、删、改、查操作#xff1b;还可以实时地将学生的信息保存到磁盘文件中。 1.1 需求分析 为了顺应互联网时代…
一、学生信息管理系统 本文使用Python语言开发了一个学生信息管理系统该系统可以帮助教师快速录入学生的信息并且对学生的信息进行基本的增、删、改、查操作还可以实时地将学生的信息保存到磁盘文件中。 1.1 需求分析 为了顺应互联网时代用户的获取数据需求学生信息管理系统应该具备以下功能
添加学生及成绩信息将学生信息保存到文件中修改和删除学生信息查询学生信息
1.2 系统设计
1.2.1 系统功能结构 学生信息管理系统分为5大功能模块主要包括添加学生信息模块、删除学生信息模块、修改学生信息模块、查询学生信息模块、显示全部学生信息模块。学生信息管理系统的功能结构如图1.1所示。 图1.1 系统功能结构图 1.2.2 系统业务流程 在开发学生信息管理系统前需要先了解系统的业务流程。根据学生信息管理系统的需求分析及功能结构设计如图1.2所示的系统业务流程。 图1.2所示的系统业务流程 1.3 系统开发必备
1.3.1 系统开发环境
本系统的软件开发及运行环境具体如下
操作系统Windows10Python版本Python 3.9开发工具Python IDLEPython内置模块tkinter。 基本上python3以上版本都能运行使用之前须安装tkinter。 1.3.2 文件夹组织结构 学生信息管理系统的文件夹结构比较简单只包括一个Python文件。在运行程序时会在项目的根目录下自动创建一个名称为students_info.txt文件用于保存学生信息。
1.4 主函数设计
在学生信息管理系统中主要包括添加学生信息、修改学生信息删除学生信息查询和显示学生信息这些学生信息会保存到磁盘文件。
1.4.1 实现添加学生信息功能
1.4.1.1 代码实现
def Add_Student_Info(ID, Name, Major, Score, Class):# 导入信息global Info# 检查输入信息是否规范if not is_ID(ID):Tip_Add_ID()returnfor i in Info:if ID i[ID]:Tip_Add_ID_Repeat()returnif not is_Score(Score):Tip_Add_Score()returnif not is_Class(Class):Tip_Add_Class()return# 用字典整合学生信息Info_dict {ID: ID, Name: Name, Major: Major, Score: Score, Class: Class}# 将字典存入总列表Info.append(Info_dict)# 添加成功Tip_Add()# 将信息写入文件WriteTxt_w_Mode(Info)1.4.1.2 代码解释
这是一个Python的函数定义其功能是添加学生信息并存储在列表和文件中。以下是这个函数的具体解析
导入信息该函数首先导入了全局变量Info。这个变量可能是在其他地方定义的用来存储所有学生的信息。检查输入信息是否规范接下来的部分是检查输入的信息是否满足特定的要求。这些检查包括检查学生的ID是否符合规定的格式检查分数是否在合理范围内以及检查班级信息是否规范。检查ID是否重复然后它检查新学生的ID是否已经在Info列表中存在。如果存在说明这个ID已经被使用过函数就会输出提示信息并返回。整合学生信息如果所有检查都通过函数就会创建一个新的字典其中包含了学生的所有信息ID名字主修专业分数班级。添加学生信息到列表然后这个字典被添加到Info列表中。输出添加成功的提示信息添加成功后函数会输出一个提示信息。将信息写入文件最后函数会将Info列表写入一个文本文件中。
1.4.1.3 效果展示 添加学生信息 1.4.2 实现删除学生信息功能
1.4.2.1 代码实现
def Del_Student_Info(ID):# 检查输入信息是否规范if not is_ID(ID):Tip_Add_ID()return# 用于指示是否删除的状态指标Flag True# 导入信息global Info# 遍历删除学生信息for i in Info:if ID i[ID]:Info.remove(i)Flag Falsebreakif Flag:Tip_Del_ID_None()return# 删除成功Tip_Del()# 将删除后的信息写入文件WriteTxt_w_Mode(Info)1.4.2.2 代码解释
这段代码定义了一个函数Del_Student_Info(ID)该函数用于删除学生信息。
代码的逻辑如下
首先检查输入的ID是否符合规范如果不符合规范则调用Tip_Add_ID()函数提示输入不规范并返回。定义一个布尔变量Flag用于指示是否删除的状态指标初始值为True。导入全局变量Info该变量应该是一个包含学生信息的列表。遍历Info列表对于每个元素判断其ID是否与输入的ID相同。如果找到了匹配的ID调用Info.remove(i)删除该元素并将Flag设置为False然后跳出循环。如果遍历结束后Flag仍然为True说明没有找到匹配的ID调用Tip_Del_ID_None()函数提示删除失败并返回。如果找到了匹配的ID并成功删除调用Tip_Del()函数提示删除成功。最后调用WriteTxt_w_Mode(Info)函数将删除后的信息写入文件。
1.4.2.3 效果展示 删除学生信息 1.4.3 实现修改学生信息功能
1.4.3.1 代码实现
def Mod_Student_Info_1(ID, Name, Major, Score, Class):# 检查输入信息是否规范if not is_ID(ID):Tip_Add_ID()returnif not is_Score(Score):Tip_Add_Score()returnif not is_Class(Class):Tip_Add_Class()return# 导入信息global Info# 遍历修改学生信息for i in Info:if i[ID] ID:i[Name] Namei[Major] Majori[Score] Scorei[Class] Class# 修改成功Tip_Mod()# 将修改后的信息写入文件WriteTxt_w_Mode(Info)
1.4.3.2 代码解释
这段代码定义了一个函数Mod_Student_Info_1(ID, Name, Major, Score, Class)该函数用于修改学生信息。
代码的逻辑如下
首先检查输入的ID、Score和Class是否符合规范如果不符合规范则分别调用相应的提示函数并返回。导入全局变量Info该变量应该是一个包含学生信息的列表。遍历Info列表对于每个元素判断其ID是否与输入的ID相同。如果找到了匹配的ID将该元素中的Name、Major、Score和Class分别修改为输入的值。如果遍历结束后仍然没有找到匹配的ID则说明要修改的学生信息不存在可能需要进行额外的处理。如果找到了匹配的ID并成功删除调用Tip_Mod()函数提示修改成功。最后调用WriteTxt_w_Mode(Info)函数将修改后的信息写入文件。
1.4.3.3 效果展示 修改学生信息 1.4.4 实现查询学生信息功能
1.4.4.1 代码实现
def Search_Student_Info(ID):# 检查输入是否规范规范的和空字符串通过if len(ID) ! 0 and not is_ID(ID):Tip_Add_ID()return# 导入信息global Info# 临时列表List []# 用来指示是否查找到学生的信息指标Flag False# 遍历根据输入的部分信息找到符合条件的学生for i in Info:if (i[ID] ID or len(ID) 0) and \(len(ID) ! 0):List.append(i)if len(List) ! 0:Flag True# 在主界面打印符合条件学生信息Print_Student_Info(List)# 是否查找成功if Flag:Tip_Search()else:Tip_Search_None()1.4.4.2 代码解释
这段代码定义了一个函数Search_Student_Info(ID)该函数用于根据输入的部分信息查找符合条件的学生信息。
代码的逻辑如下
首先检查输入的ID是否规范如果不规范则调用Tip_Add_ID()函数提示输入不规范并返回。导入全局变量Info该变量应该是一个包含学生信息的列表。创建一个空的临时列表List用于存储符合条件的学生信息。定义一个布尔变量Flag用于指示是否查找到学生的信息初始值为False。遍历Info列表对于每个元素判断其ID是否与输入的ID相同并根据条件筛选符合要求的学生信息。如果找到了符合条件的学生信息将其添加到List列表中。判断List列表的长度是否为0如果不为0说明找到了符合条件的学生信息将Flag设置为True。调用Print_Student_Info(List)函数在主界面打印符合条件的学生信息。根据Flag的值判断查找是否成功如果成功调用Tip_Search()函数提示查找成功否则调用Tip_Search_None()函数提示查找失败。
1.4.4.3 效果展示 查询学生信息 1.4.5 实现显示学生信息功能
1.4.5.1 代码实现
def Print_Student_Info(Student_Info):# 定义一个字符串用于存储想要输出显示的内容str_out # 学生信息为空将返回if Student_Info is None:result.set(学生信息为空)returnif len(Student_Info) 0:result.set(无学生信息)return# 学生信息不为空if len(Student_Info) ! 0:str_out 学生信息如下\n# 显示信息标题str_out ({:^7}.format(学生学号) {:^7}.format(学生姓名) {:^7}.format(学生专业) {:^7}.format(学生分数) {:^5}.format(班级) \n)for i in range(0, len(Student_Info)):# 格式化字符串str_out ({:^}.format(Student_Info[i].get(ID)) *(11-Len_Str(Student_Info[i].get(ID))) {:^}.format(Student_Info[i].get(Name)) *(11-Len_Str(Student_Info[i].get(Name))){:^}.format(Student_Info[i].get(Major)) *(13-Len_Str(Student_Info[i].get(Major))){:^}.format(Student_Info[i].get(Score)) *(10-Len_Str(Student_Info[i].get(Score))){:^}.format(Student_Info[i].get(Class)) *(5-Len_Str(Student_Info[i].get(Class)))\n)# 在主界面显示学生信息result.set(str_out)
1.4.5.2 代码解释
这段代码定义了一个函数Print_Student_Info(Student_Info)用于在界面上展示学生信息。
代码的逻辑如下
首先检查输入的Student_Info是否为空如果是则将结果设置为学生信息为空并返回。如果Student_Info的长度为0则将结果设置为无学生信息并返回。如果Student_Info不为空且长度不为0进行以下操作 创建一个空的字符串str_out用于存储要输出的内容。添加一个字符串表示学生信息的标题。遍历Student_Info列表中的每个元素对于每个学生信息按照指定的格式将其添加到str_out中。 使用{:^}格式化字符串来对齐每个字段其中^表示居中对齐。使用Len_Str()函数获取每个字段的长度以确保对齐的正确性。最后将str_out设置为result的属性值以在主界面上显示学生信息。 1.4.5.3 效果展示 显示学生信息 1.5 窗口函数
1.5.1 添加学生信息窗口
def Window_Add():# 实例化对象创建root的子窗口windowwindow tk.Toplevel(root)# 窗口名字window.title(添加学生信息)# 窗口大小window.geometry(500x500)# 关于学号的 label 和 entryTxt_ID tk.StringVar()Txt_ID.set()Label_Line1 tk.Label(window, text学 号 (6 位), font(Arial, 10), width15).place(x75, y50, anchornw)Entry_Line1 tk.Entry(window, showNone, font(宋体, 15), textvariableTxt_ID, width20)Entry_Line1.place(x200, y50, anchornw)# 关于姓名的 label 和 entryTxt_Name tk.StringVar()Txt_Name.set()Label_Line2 tk.Label(window, text姓 名, font(Arial, 10), width15).place(x75, y100, anchornw)Entry_Line2 tk.Entry(window, showNone, font(宋体, 15), textvariableTxt_Name, width20)Entry_Line2.place(x200, y100, anchornw)# 关于专业的 label 和 entryTxt_Major tk.StringVar()Txt_Major.set()Label_Line3 tk.Label(window, text专 业, font(Arial, 10), width15).place(x75, y150, anchornw)Entry_Line3 tk.Entry(window, showNone, font(宋体, 15), textvariableTxt_Major, width20)Entry_Line3.place(x200, y150, anchornw)# 关于分数的 label 和 entryTxt_Score tk.StringVar()Txt_Score.set()Label_Line4 tk.Label(window, text分 数 (0~100), font(Arial, 10), width15).place(x75, y200,anchornw)Entry_Line4 tk.Entry(window, showNone, font(宋体, 15), textvariableTxt_Score, width20)Entry_Line4.place(x200, y200, anchornw)# 关于班级的 label 和 entryTxt_Class tk.StringVar()Txt_Class.set()Label_Line5 tk.Label(window, text班 级 (序号), font(Arial, 10), width15).place(x75, y250, anchornw)Entry_Line5 tk.Entry(window, showNone, font(宋体, 15), textvariableTxt_Class, width20)Entry_Line5.place(x200, y250, anchornw)# 关于确认组件此处绑定函数Add_Student_Info用于添加学生信息Button1_Yes tk.Button(window, text确认, bgsilver, font(Arial, 12),commandlambda: Add_Student_Info(Txt_ID.get(), Txt_Name.get(), Txt_Major.get(),Txt_Score.get(), Txt_Class.get()), width10)Button1_Yes.place(x75, y400, anchornw)# 关于取消组件此处绑定函数destroy()用于关闭窗口Button2_No tk.Button(window, text取消, bgsilver, font(Arial, 12), commandlambda: window.destroy(),width10)Button2_No.place(x325, y400, anchornw)# 窗口显示window.mainloop()
1.5.2 删除学生信息窗口 # 删除学生信息的窗口
def Window_Del():# 创建root的子窗口window tk.Toplevel(root)window.title(删除学生信息)window.geometry(500x300)# 关于学号的 label 和 entryTxt_ID tk.StringVar()Txt_ID.set()Label_Line1 tk.Label(window, text学 号 (6 位), font(Arial, 10), width15).place(x75, y100, anchornw)Entry_Line1 tk.Entry(window, showNone, font(宋体, 15), textvariableTxt_ID, width20)Entry_Line1.place(x200, y100, anchornw)# 关于确认组件此处绑定函数Del_Student_Info用于删除学生信息Button1_Yes tk.Button(window, text确认, bgsilver, font(Arial, 12),commandlambda: Del_Student_Info(Txt_ID.get()), width10)Button1_Yes.place(x75, y200, anchornw)# 关于取消组件此处绑定函数destroy()用于关闭窗口Button2_No tk.Button(window, text取消, bgsilver, font(Arial, 12), commandlambda: window.destroy(),width10)Button2_No.place(x325, y200, anchornw)# tk.StringVar()用于接收用户输入result tk.StringVar()result.set(请先通过查询学生信息查询待删除学生的学号)# 在界面中显示文本框,打印result的信息Show_result tk.Label(window, bgwhite, fgblack, font(宋体, 12), bd0, anchornw, textvariableresult)Show_result.place(x50, y50, width400, height50)# 显示窗口window.mainloop()1.5.3 修改学生信息窗口
def Window_Mod():# 创建root的子窗口window tk.Toplevel(root)window.title(修改学生信息)window.geometry(500x300)# 关于学号的 label 和 entryTxt_ID tk.StringVar()Txt_ID.set()Label_Line1 tk.Label(window, text学 号 (6 位), font(Arial, 10), width15).place(x75, y100, anchornw)Entry_Line1 tk.Entry(window, showNone, font(宋体, 15), textvariableTxt_ID, width20)Entry_Line1.place(x200, y100, anchornw)# 关于确认组件此处绑定函数Mod_Student_Info用于修改学生信息Button1_Yes tk.Button(window, text确认, bgsilver, font(Arial, 12),commandlambda: Mod_Student_Info(Txt_ID.get()), width10)Button1_Yes.place(x75, y200, anchornw)# 关于取消组件此处绑定函数destroy()用于关闭窗口Button2_No tk.Button(window, text取消, bgsilver, font(Arial, 12), commandlambda: window.destroy(),width10)Button2_No.place(x325, y200, anchornw)# 在界面中显示文本框,打印result的信息result tk.StringVar()result.set(请先通过查询学生信息查询待修改学生的学号)Show_result tk.Label(window, bgwhite, fgblack, font(宋体, 12), bd0, anchornw, textvariableresult)Show_result.place(x50, y50, width400, height50)# 显示窗口window.mainloop()
1.5.4 输入修改学生信息窗口
def Window_Mod_Input(ID):# 创建root的子窗口window tk.Toplevel(root)window.title(修改学生信息)window.geometry(500x500)# 关于姓名的 label 和 entryTxt_Name tk.StringVar()Txt_Name.set()Label_Line2 tk.Label(window, text姓 名, font(Arial, 10), width15).place(x75, y100, anchornw)Entry_Line2 tk.Entry(window, showNone, font(宋体, 15), textvariableTxt_Name, width20)Entry_Line2.place(x200, y100, anchornw)# 关于专业的 label 和 entryTxt_Major tk.StringVar()Txt_Major.set()Label_Line3 tk.Label(window, text专 业, font(Arial, 10), width15).place(x75, y150, anchornw)Entry_Line3 tk.Entry(window, showNone, font(宋体, 15), textvariableTxt_Major, width20)Entry_Line3.place(x200, y150, anchornw)# 关于分数的 label 和 entryTxt_Score tk.StringVar()Txt_Score.set()Label_Line4 tk.Label(window, text分 数 (0~100), font(Arial, 10), width15).place(x75, y200,anchornw)Entry_Line4 tk.Entry(window, showNone, font(宋体, 15), textvariableTxt_Score, width20)Entry_Line4.place(x200, y200, anchornw)# 关于班级的 label 和 entryTxt_Class tk.StringVar()Txt_Class.set()Label_Line5 tk.Label(window, text班 级 (序号), font(Arial, 10), width15).place(x75, y250, anchornw)Entry_Line5 tk.Entry(window, showNone, font(宋体, 15), textvariableTxt_Class, width20)Entry_Line5.place(x200, y250, anchornw)# 关于确认组件此处绑定函数Mod_Student_Info_1用于修改学生信息Button1_Yes tk.Button(window, text确认, bgsilver, font(Arial, 12),commandlambda: Mod_Student_Info_1(ID, Txt_Name.get(), Txt_Major.get(), Txt_Score.get(),Txt_Class.get()), width10)Button1_Yes.place(x75, y400, anchornw)# 关于取消组件此处绑定函数destroy()用于关闭窗口Button2_No tk.Button(window, text取消, bgsilver, font(Arial, 12), commandlambda: window.destroy(),width10)Button2_No.place(x325, y400, anchornw)# 在界面中显示文本框,打印result的信息result tk.StringVar()result.set( 请输入修改后的信息)Show_result tk.Label(window, bgwhite, fgblack, font(宋体, 12), bd0, anchornw, textvariableresult)Show_result.place(x50, y50, width400, height50)# 显示窗口window.mainloop()1.5.5 查询学生信息窗口
def Window_Ser():# 创建root的子窗口window tk.Toplevel(root)window.title(查询学生信息)window.geometry(500x500)# 关于学号的 label 和 entryTxt_ID tk.StringVar()Txt_ID.set()Label_Line1 tk.Label(window, text学 号 (6 位), font(Arial, 10), width15).place(x75, y100, anchornw)Entry_Line1 tk.Entry(window, showNone, font(宋体, 15), textvariableTxt_ID, width20)Entry_Line1.place(x200, y100, anchornw)# 关于确认组件此处绑定函数Search_Student_Info用于修改学生信息Button1_Yes tk.Button(window, text确认, bgsilver, font(Arial, 12),commandlambda: Search_Student_Info(Txt_ID.get()), width10)Button1_Yes.place(x75, y400, anchornw)# 关于取消组件此处绑定函数destroy()用于关闭窗口Button2_No tk.Button(window, text取消, bgsilver, font(Arial, 12), commandlambda: window.destroy(),width10)Button2_No.place(x325, y400, anchornw)# 在界面中显示文本框,打印result的信息result tk.StringVar()result.set( 请输入待查找学生的部分信息)Show_result tk.Label(window, bgwhite, fgblack, font(宋体, 12), bd0, anchornw, textvariableresult)Show_result.place(x50, y50, width400, height50)# 显示窗口window.mainloop()1.5.6 退出窗口
def Window_Exit():# 创建root的子窗口window tk.Toplevel()window.title(退出管理系统)window.geometry(400x300)# 关于确认组件此处绑定函数destroy()用于关闭主窗口Button1_Yes tk.Button(window, text确认, bgsilver, font(Arial, 12), commandlambda: root.destroy(),width10)Button1_Yes.place(x50, y200, anchornw)# 关于取消组件此处绑定函数destroy()用于关闭窗口Button2_No tk.Button(window, text取消, bgsilver, font(Arial, 12), commandlambda: window.destroy(),width10)Button2_No.place(x250, y200, anchornw)# 在界面中显示文本框,打印result的信息result tk.StringVar()
1.6 调用函数
1.6.1 主窗口函数
if __name__ __main__:# 创建主窗口root tk.Tk()root.title(学生信息管理系统 V1.1)root.geometry(900x400)# 关于添加学生信息组件此处绑定函数Search_Student_Info用于修改学生信息Button1_Add tk.Button(root, text添 加 学 生 信 息, bgsilver, font(Arial, 12), commandWindow_Add,width20)Button1_Add.place(x50, y50, anchornw)Button2_Del tk.Button(root, text删 除 学 生 信 息, bgsilver, font(Arial, 12), commandWindow_Del,width20)Button2_Del.place(x50, y100, anchornw)Button3_Mod tk.Button(root, text修 改 学 生 信 息, bgsilver, font(Arial, 12), commandWindow_Mod,width20)Button3_Mod.place(x50, y150, anchornw)Button4_Ser tk.Button(root, text查 询 学 生 信 息, bgsilver, font(Arial, 12), commandWindow_Ser,width20)Button4_Ser.place(x50, y200, anchornw)Button5_Show tk.Button(root, text显 示 学 生 信 息, bgsilver, font(Arial, 12),commandlambda: Print_Student_Info(Info), width20)Button5_Show.place(x50, y250, anchornw)Button6_Exit tk.Button(root, text退 出 管 理 系 统, bgsilver, font(Arial, 12), commandWindow_Exit,width20)Button6_Exit.place(x50, y300, anchornw)result tk.StringVar()Show_result tk.Label(root, bgwhite, fgblack, font(宋体, 12), bd0, anchornw, textvariableresult)Show_result.place(x300, y50, width520, height300)root.mainloop()
1.6.2 学生信息写入文件函数
def WriteTxt_w_Mode(Student_List):# w:只写入模式文件不存在则建立将文件里边的内容先删除再写入with open(Student_Info.txt, w, encodingutf-8) as f:for i in range(0, len(Student_List)):Info_dict Student_List[i]# 最后一行不写入换行符\nif i len(Student_List) - 1:f.write({0}\t{1}\t{2}\t{3}\t{4}.format \(Info_dict[ID], Info_dict[Name], Info_dict[Major], Info_dict[Score],Info_dict[Class]))else:f.write({0}\t{1}\t{2}\t{3}\t{4}\n.format \(Info_dict[ID], Info_dict[Name], Info_dict[Major], Info_dict[Score],Info_dict[Class]))1.6.3 学生信息文件读取函数
def ReadTxt() - list:# 临时列表Temp_List1 []Temp_List2 []# 打开同目录下的文件f open(./Student_Info.txt, r, encodingutf-8)# 遍历读取文件每一行信息for i in f:a str(i)b a.replace(\n, )Temp_List1.append(b.split(\t))# 将读写的信息并入临时列表while len(Temp_List2) len(Temp_List1):for j in range(0, len(Temp_List1)):ID Temp_List1[j][0]Name Temp_List1[j][1]Major Temp_List1[j][2]Score Temp_List1[j][3]Class Temp_List1[j][4]Info_dict {ID: ID,Name: Name,Major: Major,Score: Score,Class: Class}Temp_List2.append(Info_dict)# 关闭文件f.close()# 将含有学生信息的临时列表返回return Temp_List2
1.6.3 检查输入是否规范函数
# 定于一个方法用于检查年龄是否规范
def is_Score(Score):return Score.isdigit() and 0 int(Score) and int(Score) 100# 定于一个方法用于检查班级是否规范
def is_Class(Class):return Class.isdigit() and int(Class) 0# 定义一个方法用于判断是否为中文字符
def is_Chinese(ch):if ch \u4e00 and ch \u9fa5:return Trueelse:return False# 定义一个方法用于计算中西文混合字符串的字符串长度
def Len_Str(string):count 0for line in string:if is_Chinese(line):count count 2else:count count 1return count
1.6.4 提示函数
def Tip_Add():messagebox.showinfo(提示信息, 添加成功)def Tip_Search():messagebox.showinfo(提示信息, 查询成功)def Tip_Del():messagebox.showinfo(提示信息, 删除成功)def Tip_Mod():messagebox.showinfo(提示信息, 修改成功)def Tip_Add_ID_Repeat():messagebox.showinfo(提示信息, 此学号已经存在请勿重复添加)def Tip_Del_ID_None():messagebox.showinfo(提示信息, 此学号不存在请重新输入)def Tip_Search_None():messagebox.showinfo(提示信息, 未查询到有关学生信息)def Tip_Add_ID():messagebox.showinfo(提示信息, 学号格式有误请重新输入)def Tip_Add_Score():messagebox.showinfo(提示信息, 分数格式有误请重新输入)def Tip_Add_Class():messagebox.showinfo(提示信息, 班级格式有误请重新输入)
1.7 打包为.exe可执行文件 Python项目完成后可以将其打包成一个.exe可执行文件这样就可以在其他计算机上运行该项目了即时这台计算机上没有安装Python开发环境。 实现打包.exe可执行文件时需要使用PyInstaller模块该模块为第三方模块所以需要单独安装。PyInstaller模块支持多种操作系统如Windows、Linux、Mac OS X等但是该模块并不支持跨平台操作。例如在Windows操作系统下打包的.exe可执行文件该文件就只能在Windows环境下运行。 这里以Windows操作系统为例介绍PyInstaller模块的安装安装PyInstaller模块最简单的方法就是在“命令提示符窗口”中输入“pip install pyinstaller”命令进行安装如图所示。如果是升级或者是更新可以使用“pip install --upgrade pyinstaller”命令。
在Windows操作系统中使用pip或者easy_install安装PyInstaller模块时会自动安装PyWin32。PyInstaller模块安装完成以后可以在“命令提示符窗口”中输入“pyinstaller--version”命令通过查询PyInstaller模块版本的方式检测安装是否成功。
PyInstaller模块安装完成以后就可以打包.py文件为.exe文件了。具体方法如下。
pyinstaller studentsystem.py
1.8 小结 本节主要使用Python语言开发了一个学生信息管理系统项目的核心是对文件、列表和字典进行操作。其中对文件进行操作是用来永久保存学生信息而将学生信息以字典的形式存储到列表中是为了方便对学生信息的查找、修改和删除。通过本节的学习读者首先应该熟练并掌握对文件进行创建、打开和修改等操作的方法其次还应该掌握对字典和列表进行操作的方法尤其是对列表进行自定义排序规则这是本项目的难点需要读者仔细体会并做到融会贯通。 源码在评论区评论“666获取学生管理系统源码” 文章转载自: http://www.morning.jbctp.cn.gov.cn.jbctp.cn http://www.morning.ycgrl.cn.gov.cn.ycgrl.cn http://www.morning.qcztm.cn.gov.cn.qcztm.cn http://www.morning.jqpyq.cn.gov.cn.jqpyq.cn http://www.morning.xkzmz.cn.gov.cn.xkzmz.cn http://www.morning.jsrnf.cn.gov.cn.jsrnf.cn http://www.morning.lbgfz.cn.gov.cn.lbgfz.cn http://www.morning.xkbdx.cn.gov.cn.xkbdx.cn http://www.morning.yqwsd.cn.gov.cn.yqwsd.cn http://www.morning.wglhz.cn.gov.cn.wglhz.cn http://www.morning.brfxt.cn.gov.cn.brfxt.cn http://www.morning.zwzwn.cn.gov.cn.zwzwn.cn http://www.morning.czwed.com.gov.cn.czwed.com http://www.morning.dhyzr.cn.gov.cn.dhyzr.cn http://www.morning.txkrc.cn.gov.cn.txkrc.cn http://www.morning.qgmbx.cn.gov.cn.qgmbx.cn http://www.morning.rfxyk.cn.gov.cn.rfxyk.cn http://www.morning.rdpps.cn.gov.cn.rdpps.cn http://www.morning.kwfnt.cn.gov.cn.kwfnt.cn http://www.morning.zgnng.cn.gov.cn.zgnng.cn http://www.morning.lzbut.cn.gov.cn.lzbut.cn http://www.morning.mprtj.cn.gov.cn.mprtj.cn http://www.morning.jqcrf.cn.gov.cn.jqcrf.cn http://www.morning.fsnhz.cn.gov.cn.fsnhz.cn http://www.morning.qwpyf.cn.gov.cn.qwpyf.cn http://www.morning.ttxnj.cn.gov.cn.ttxnj.cn http://www.morning.pzrnf.cn.gov.cn.pzrnf.cn http://www.morning.zlxkp.cn.gov.cn.zlxkp.cn http://www.morning.rcww.cn.gov.cn.rcww.cn http://www.morning.gmwqd.cn.gov.cn.gmwqd.cn http://www.morning.xgcwm.cn.gov.cn.xgcwm.cn http://www.morning.jqcrf.cn.gov.cn.jqcrf.cn http://www.morning.pnmgr.cn.gov.cn.pnmgr.cn http://www.morning.hxlpm.cn.gov.cn.hxlpm.cn http://www.morning.srgwr.cn.gov.cn.srgwr.cn http://www.morning.rnmc.cn.gov.cn.rnmc.cn http://www.morning.rbcw.cn.gov.cn.rbcw.cn http://www.morning.crsqs.cn.gov.cn.crsqs.cn http://www.morning.spqtq.cn.gov.cn.spqtq.cn http://www.morning.hjssh.cn.gov.cn.hjssh.cn http://www.morning.ftync.cn.gov.cn.ftync.cn http://www.morning.bmts.cn.gov.cn.bmts.cn http://www.morning.tmrjb.cn.gov.cn.tmrjb.cn http://www.morning.kwfnt.cn.gov.cn.kwfnt.cn http://www.morning.lywpd.cn.gov.cn.lywpd.cn http://www.morning.srnth.cn.gov.cn.srnth.cn http://www.morning.hhnhb.cn.gov.cn.hhnhb.cn http://www.morning.gfqjf.cn.gov.cn.gfqjf.cn http://www.morning.mnyzz.cn.gov.cn.mnyzz.cn http://www.morning.zfcfk.cn.gov.cn.zfcfk.cn http://www.morning.nlqgb.cn.gov.cn.nlqgb.cn http://www.morning.rdmz.cn.gov.cn.rdmz.cn http://www.morning.i-bins.com.gov.cn.i-bins.com http://www.morning.kdnrp.cn.gov.cn.kdnrp.cn http://www.morning.qqbjt.cn.gov.cn.qqbjt.cn http://www.morning.wyrsn.cn.gov.cn.wyrsn.cn http://www.morning.dkgtr.cn.gov.cn.dkgtr.cn http://www.morning.kkgbs.cn.gov.cn.kkgbs.cn http://www.morning.dpruuode.cn.gov.cn.dpruuode.cn http://www.morning.jqsyp.cn.gov.cn.jqsyp.cn http://www.morning.xznrk.cn.gov.cn.xznrk.cn http://www.morning.pgcmz.cn.gov.cn.pgcmz.cn http://www.morning.lskyz.cn.gov.cn.lskyz.cn http://www.morning.drcnn.cn.gov.cn.drcnn.cn http://www.morning.bloao.com.gov.cn.bloao.com http://www.morning.hytfz.cn.gov.cn.hytfz.cn http://www.morning.mwjwy.cn.gov.cn.mwjwy.cn http://www.morning.rfpb.cn.gov.cn.rfpb.cn http://www.morning.tmxtr.cn.gov.cn.tmxtr.cn http://www.morning.hpspr.com.gov.cn.hpspr.com http://www.morning.yfnjk.cn.gov.cn.yfnjk.cn http://www.morning.rqxtb.cn.gov.cn.rqxtb.cn http://www.morning.cknws.cn.gov.cn.cknws.cn http://www.morning.jrslj.cn.gov.cn.jrslj.cn http://www.morning.wprxm.cn.gov.cn.wprxm.cn http://www.morning.bsqbg.cn.gov.cn.bsqbg.cn http://www.morning.fhghy.cn.gov.cn.fhghy.cn http://www.morning.rjnky.cn.gov.cn.rjnky.cn http://www.morning.ykmkz.cn.gov.cn.ykmkz.cn http://www.morning.skkln.cn.gov.cn.skkln.cn