python编写学生成绩管理系统的逻辑结构及功能怎么实现


这篇“python编写学生成绩管理系统的逻辑结构及功能怎么实现”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“python编写学生成绩管理系统的逻辑结构及功能怎么实现”文章吧。

学生信息系统

提示:python编写的学生成绩管理系统,包括8个功能和打包教程

一、功能界面

defmenum():print('==================student_manger=================')print('---------------------功能界面---------------------')print('\t\t1.录入学生信息')print('\t\t2.查找学生信息')print('\t\t3.删除学生信息')print('\t\t4.修改学生成绩')print('\t\t5.排序')print('\t\t6.统计学生总人数')print('\t\t7.显示所有学生信息')print('\t\t8.显示功能介绍按钮')print('\t\t0.退出')print('================================================')

二 、主函数

defmain():menum()whileTrue:try:choice=int(input('请选择你想进行的操作:'))exceptValueError:print('输入的数据存在错误,只能输入0到7的整数!')try:choice=int(input('请重新输入:'))exceptValueError:print('重复输入错误,退出系统!')breakifchoicein[0,1,2,3,4,5,6,7,8]:ifchoice==0:answer=input('你确定要退出系统吗?(Y/N):')ifanswer=='Y'oranswer=='y':print('谢谢使用!')breakelifanswer=='N'oranswer=='n':print('即将返回上一步操作!')continueelse:input('输入错误,即将返回主界面!')continueelifchoice==1:insert()elifchoice==2:search()elifchoice==3:delete()elifchoice==4:modify()elifchoice==5:sort()elifchoice==6:total()elifchoice==7:show()else:menum()else:print('你选择的操作无效,请重新输入!:')

三 、学生信息录入功能

逻辑结构图

definsert():student_list=[]id_list=[]whileTrue:id=input('请输入ID:')ifnotid:breakname=input('请输入姓名:')ifnotname:breaktry:english=float(input('请输入英语成绩:'))math=float(input('请输入数学成绩:'))python=float(input('请输入Python成绩:'))exceptValueError:print('数据输入错误!')continue#将录入的学生信息存放到字典中student={'id':id,'name':name,'english':english,'math':math,'Python':python}#将每个学生的信息存放在列表中ifstudent['id']inid_list:#student['id']=value(id)print('已存在相同ID:')foriinrange(len(student_list)):ifstudent_list[i][id]==student[id]:#输出重复id元素print(student_list[i].items())breakprint('请重新录入!')else:id_list.append(str(student['id']))student_list.append(student)#是否继续添加学生信息answer=input('是否继续添加学生信息?(Y/N):')ifanswer=='Y'oranswer=='y':continueelifanswer=='N'oranswer=='n':#存储学生信息save(student_list,filename)print('学生信息录入完毕!')breakelse:print('输入错误,即将返回主界面!')break

四 、学生信息查找功能

逻辑结构图

代码

defsearch():whileTrue:ifos.path.exists(filename):withopen(filename,'r',encoding='utf-8')ass_file:student_qurey=s_file.readlines()#将学生信息全部取出id_list=[]name_list=[]foriinstudent_qurey:d=dict(eval(i))id_list.append(d['id'])#将所有学生的id存放在id_list中name_list.append(d['name'])#将所有学生的name存放在id_list中try:mode=int(input('请选择查询模式:1.按照ID查询/2.按照姓名查询'))exceptValueError:print('数据类型输入错误!请重新输入!')else:ifmode==1:#按照ID查询id=input('请输入学生id:')ifidinid_list:print('已经查找到该名学生:')print('ID\t\t\t姓名:\t\t英语成绩:\t\t数学成绩:\t\tPython成绩:\t\t总成绩:')foriteminstudent_qurey:ifdict(eval(item))['id']==id:p=dict(eval(item))print('{0}\t\t{1}\t\t{2}\t\t{3}\t\t{4}\t\t{5}'.format(p['id'],p['name'],p['english'],p['math'],p['Python'],float(p['english'])+float(p['math'])+float(p['Python'])))else:print('查无此人!')elifmode==2:#按照姓名查询name=input('请输入学生姓名:')ifnameinname_list:print('已经查找到该名学生:')print('ID\t\t\t姓名:\t\t英语成绩:\t\t数学成绩:\t\tPython成绩:\t\t总成绩:')foriteminstudent_qurey:ifdict(eval(item))['name']==name:p=dict(eval(item))print('{0}\t\t{1}\t\t{2}\t\t{3}\t\t{4}\t\t{5}'.format(p['id'],p['name'],p['english'],p['math'],p['Python'],float(p['english'])+float(p['math'])+float(p['Python'])))else:print('查无此人!')else:print('输入错误,只能选择1/2两种模式!')answer=input('是否继续查询?(Y/N)')ifanswer=='Y'oranswer=='y':continueelifanswer=='N'oranswer=='n':print('正在退出查询..')breakelse:print('输入错误,即将返回主界面!')breakelse:print('无学生信息文件!')return

五 、删除学生信息

逻辑结构图

代码

defdelete():whileTrue:student_id=input('请输入想要删除的学生的ID:')ifstudent_id!='':ifos.path.exists(filename):withopen(filename,'r',encoding='utf-8')asfile:student_old=file.readlines()else:student_old=[]flag=False#标记是否删除ifstudent_old:withopen(filename,'w',encoding='utf-8')aswfile:foriteminstudent_old:d=dict(eval(item))#转化为字典类型ifd['id']!=student_id:wfile.write(str(d)+'\n')else:flag=Trueifflag:print(f'id为{student_id}的学生信息已被删除!')else:print(f'没有找到id为{student_id}的学生信息!')else:print('无学生信息')breakshow()#显示更新后的文件信息answer=input('是否继续删除学生信息?(Y/N):')ifanswer=='Y'oranswer=='y':continueelifanswer=='N'oranswer=='n':breakelse:print('输入错误,即将返回主界面!')break

六 、学生信息修改功能

逻辑结构图

代码

defmodify():show()ifos.path.exists(filename):withopen(filename,'r',encoding='utf-8')asrfile:student_old=rfile.readlines()#直接将文本文件的内容整行读取到列表中else:print('学生文件信息不存在!')student_id=input('请输入想要修改的学生的ID:')withopen(filename,'w',encoding='utf-8')asjust_file:#判断学生是否在该系统中id_list=[]foriinstudent_old:d=dict(eval(i))id_list.append(d['id'])#将所有学生的id存放在id_list中ifstudent_idinid_list:#要修改的学生存在时foriteminstudent_old:e=dict(eval(item))ife['id']==student_id:print('已找到该名学生!')whileTrue:try:e['name']=input('请输入姓名:')e['english']=input('请输入英语成绩:')e['math']=input('请输入数学成绩:')e['Python']=input('请输入Python成绩:')exceptValueError:print('数据类型输入错误!请重新输入!')else:break#try...except..else:输入为出错时,执行else语句just_file.write(str(e)+'\n')print('修改成功!')else:just_file.write(str(e)+'\n')else:answer1=input('查无此人!,是否执行插入操作?(Y/N)')ifanswer1=='Y'oranswer1=='y':insert()else:print('结束当前操作')answer=input('是否继续修改其余学生信息?(Y/N):')ifanswer=='Y'oranswer=='y':modify()elifanswer=='N'oranswer=='n':print('结束修改,即将返回主界面..')else:print('输入错误,即将返回主界面!')

七 、学生成绩排序

逻辑结构图

代码

defsort():student_new=[]ifos.path.exists(filename):withopen(filename,'r',encoding='utf-8')assort_file:student_list=sort_file.readlines()#无序的学生信息列表foriteminstudent_list:d=dict(eval(item))student_new.append(d)#列表元素转化为字典whileTrue:try:sort_choice=int(input('请选择排序方式:0:升序/1:降序\t'))exceptValueError:print('输入的数据类型错误,请重新输入')else:ifsort_choice==0:Flag=Falsebreakelifsort_choice==1:Flag=Truebreakelse:print('输入错误,只能在0/1中选择!')continuewhileTrue:try:asc_choice=int(input('请选择按照哪一门成绩进行排序:英语:0/数学:1/python:2\t\t'))exceptValueError:print('输入的数据类型错误,请重新输入')else:ifasc_choice==0:student_new.sort(key=lambdax:int(x['english']),reverse=Flag)#根据列表中的元素进行排序show()breakelifasc_choice==1:student_new.sort(key=lambdax:int(x['math']),reverse=Flag)show()breakelifasc_choice==2:student_new.sort(key=lambdax:int(x['Python']),reverse=Flag)show()breakelifasc_choice==3:student_new.sort(key=lambdax:int(x['Python'])+int(x['english'])+int(x['math']),reverse=Flag)show()breakelse:print('输入错误,只能在0/1/2中选择!')continueelse:print('学生信息文件不存在!')

八 、 学生人数统计

逻辑结构图

代码

deftotal():nums=0ifos.path.exists(filename):withopen(filename,'r',encoding='utf-8')ast_file:len_list=t_file.readlines()foriinrange(len(len_list)):iflen_list[i]!='':nums+=1print('当前学生总人数为:',nums)print('请选择你想进行的下一步操作:')else:print('暂无学生信息文件')

九 、显示所有学生信息

逻辑结构图

代码

defshow():ifos.path.exists(filename):withopen(filename,'r',encoding='utf-8')asshow_file:student_list=show_file.readlines()ifstudent_list:print('----全部学生信息如下----')print('ID\t\t\t姓名:\t\t英语成绩:\t\t数学成绩:\t\tPython成绩:\t\t总成绩:')foriteminstudent_list:p=dict(eval(item))print('{0}\t\t{1}\t\t{2}\t\t{3}\t\t{4}\t\t{5}'.format(p['id'],p['name'],p['english'],p['math'],p['Python'],float(p['english'])+float(p['math'])+float(p['Python'])))else:print('暂无学生信息!')else:print('暂无学生信息!')

程序打包

在 pycharm 终端 或者 python命令界面, 使用:

pipinstallPyInstaller

下载python打包程序,下载完成后, 执行以下操作:

pyinstaller—FF:\xxxx\xxx\xx\x.py

其中:

  • -F 代表将程序打包为单个exe文件,

  • F:\xxx\xxx\xx.py 为你的学生成绩管理系统文件的绝对地址

打包完成后,提示信息倒数第二行:Appending语句后面即为exe文件位置,若无特殊显示,则在当前目录父文件下

以上就是关于“python编写学生成绩管理系统的逻辑结构及功能怎么实现”这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注主机评测网行业资讯频道。


上一篇:redis?for?windows6.2.6安装包使用怎么修改密码

下一篇:vue中template报错问题怎么解决


Copyright © 2002-2019 测速网 www.inhv.cn 皖ICP备2023010105号
测速城市 测速地区 测速街道 网速测试城市 网速测试地区 网速测试街道
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!

热门搜索 城市网站建设 地区网站制作 街道网页设计 大写数字 热点城市 热点地区 热点街道 热点时间 房贷计算器