Python课程设计之学生信息管理系统
Python课程设计之学生信息管理系统
- 需求分析
- 系统设计
- 主函数设计
- 录入学生信息
- 删除学生信息
- 修改学生信息
- 查找学生信息
- 统计学生总人数
- 显示所有学生信息
- 排序模块
- 项目所有源码下载地址
需求分析
系统设计
主函数设计
核心代码
def main():while True:menu()choice=int(input('请选择:'))if choice in [0,1,2,3,4,5,6,7]:if choice==0:answer=input('您确定要退出系统吗? y or n')if answer=='y' or answer=='Y':print('谢谢您的使用!!!')break # 退出系统else:continueelif choice==1:insert() #录入学生信息elif choice==2:search() #查找学生信息elif choice==3:delete() #删除学生信息elif choice==4:modify() #修改学生信息elif choice==5:sort() #排序elif choice==6:total() #统计学生总人数elif choice==7:show() #统计学生总人数#菜单
def menu():print('----------------学生信息管理系统----------------------')print('-------------------功能菜单-------------------------')print('\t\t\t\t 1.录入学生信息')print('\t\t\t\t 2.查找学生信息')print('\t\t\t\t 3.删除学生信息')print('\t\t\t\t 4.修改学生信息')print('\t\t\t\t 5.排序')print('\t\t\t\t 6.统计学生总人数')print('\t\t\t\t 7.显示所有学生信息')print('\t\t\t\t 0.退出系统')print('----------------------------------------------------')
运行效果
录入学生信息
核心代码
#录入学生信息
def insert():student_list=[]while True:id=input('请输入ID(如1001):')if not id:breakname=input('请输入姓名:')if not name:breaktry:math=int(input('请输入数学成绩:'))english=int(input('请输入英语成绩:'))chinese=int(input('请输入语文成绩:'))except:print('输入无效,不是整数类型,请重新输入')continue#将录入的学生信息保存到字典中student={'id':id,'name':name,'math':math,'english':english,'chinese':chinese}#将学生信息添加到学生列表中student_list.append(student)answer=input('是否继续添加学生信息?y or n \n')if answer=='y':continueelse:break#调用save()函数save(student_list)print('学生信息录入完毕!!!')#保存学生信息
def save(lst):try:stu_txt=open(filename,'a',encoding='utf-8')except:stu_txt=open(filename,'w',encoding='utf-8')for item in lst:stu_txt.write(str(item)+'\n')stu_txt.close()
运行效果
删除学生信息
核心代码
#删除学生信息
def delete():while True:student_id=input('请输入需要删除的学生的ID:')if student_id !='':if os.path.exists(filename):with open(filename,'r',encoding='utf-8') as file:student_old=file.readlines()else:student_old=[]flag=False #标记是否删除if student_old:with open(filename,'w',encoding='utf-8') as wfile:d={} #定义空字典for item in student_old:d=dict(eval(item)) #将字符串转成字典if d['id'] != student_id:wfile.write(str(d)+'\n')else:flag=Trueif flag:print(f'ID为{student_id}的学生信息已被删除!')else:print(f'没有找到ID为{student_id}的学生信息!')else:print('系统内无学生信息!')breakshow() #删除信息后展示系统内学生信息answer=input('是否继续删除? y or n \n')if answer=='y':continueelse:break
运行效果
修改学生信息
核心代码
#修改学生信息
def modify():show()if os.path.exists(filename):with open(filename,'r',encoding='utf-8') as rfile:student_old=rfile.readlines()else:returnstudent_id=input('请输入要修改的学生的ID:')with open(filename,'w',encoding='utf-8') as wfile:for item in student_old:d=dict(eval(item))if d['id']==student_id:print('找到学生信息,可以进行修改该学生的相关信息了!')while True:try:d['name']=input('请输入姓名:')d['math'] = input('请输入数学成绩:')d['english'] = input('请输入英语成绩:')d['chinese'] = input('请输入语文成绩:')except:print('您的输入有误,请重新输入!')else:breakwfile.write(str(d) + '\n')print('修改成功!!!')else:wfile.write(str(d) + '\n')answer=input('是否需要继续修改其他学生信息? y or n \n')if answer=='y':modify()
运行效果
查找学生信息
核心代码
#查找学生信息
def search():student_query=[]while True:id=''name=''if os.path.exists(filename):mode=input('按ID查找请输入1,按姓名查找请输入2:')if mode=='1':id=input('请输入学生ID:')elif mode=='2':name=input('请输入学生姓名:')else:print('您的输入有误,请重新输入!')search()with open(filename,'r',encoding='utf-8') as rfile:student=rfile.readlines()for item in student:d=dict(eval(item))if id != '':if d['id']==id:student_query.append(d)elif name != '':if d['name']==name:student_query.append(d)#显示查询结果show_student(student_query)#清空列表student_query.clear()answer=input('是否要继续查询? y or n \n')if answer=='y':continueelse:breakelse:print('暂未保存学生信息!')returndef show_student(lst):if len(lst)==0:print('没有查询到学生信息,无数据显示!!!')return#定义标题显示格式format_title='{:^6}\t{:^12}\t{:^8}\t{:^10}\t{:^6}\t{:^6}'print(format_title.format('ID','姓名','数学成绩','英语成绩','语文成绩','总成绩'))#定义内容显示格式format_data='{:^6}\t{:^12}\t{:^8}\t{:^10}\t{:^14}\t{:^8}'for item in lst:print(format_data.format(item.get('id'),item.get('name'),item.get('math'),item.get('english'),item.get('chinese'),int(item.get('math'))+int(item.get('english'))+int(item.get('chinese'))))
运行效果
统计学生总人数
核心代码
#统计学生总人数
def total():if os.path.exists(filename):with open(filename,'r',encoding='utf-8') as rfile:students=rfile.readlines()if students:print(f'一共有{len(students)}名学生!')else:print('还没有录入学生信息!')else:print('暂未保存数据信息.....')
运行效果
显示所有学生信息
核心代码
#展示所有学生信息
def show():student_lst=[]if os.path.exists(filename):with open(filename,'r',encoding='utf-8') as rfile:students=rfile.readlines()for item in students:student_lst.append(eval(item))if student_lst:show_student(student_lst)else:print('暂未保存过数据!!!!')
运行效果
排序模块
核心代码
#排序
def sort():show()if os.path.exists(filename):with open(filename,'r',encoding='utf-8') as rfile:student_list=rfile.readlines()student_new=[]for item in student_list:d=dict(eval(item))student_new.append(d)else:returnasc_or_desc=input('请选择排序方式,1.升序 2.降序 :')if asc_or_desc=='1':asc_or_desc_bool=Falseelif asc_or_desc=='2':asc_or_desc_bool=Trueelse:print('您的输入有误,请重新输入 :')sort()mode=input('请选择排序方式,1.按数学成绩排序 2.按英语成绩排序 3.按语文成绩排序 4.按总成绩排序 :')if mode=='1':student_new.sort(key=lambda x:int(x['math']),reverse=asc_or_desc_bool)elif mode=='2':student_new.sort(key=lambda x:int(x['english']),reverse=asc_or_desc_bool)elif mode=='3':student_new.sort(key=lambda x:int(x['chinese']),reverse=asc_or_desc_bool)elif mode=='4':student_new.sort(key=lambda x:int(x['math'])+int(x['english'])+int(x['chinese']),reverse=asc_or_desc_bool)else:print('您的输入有误,请重新输入:')sort()show_student(student_new)
运行效果
项目所有源码下载地址
点击下载
Python课程设计之学生信息管理系统相关推荐
- 【Python课程设计】学生成绩管理系统
[Python课程设计]学生成绩管理系统 1.需求分析 2.功能设计与分析 1.使用数据库对数据进行存取 (1)使用PyMySQL模块操作数据库对数据进行存取 (2)创建数据库school,创建数据表 ...
- 数据结构课程设计论文--学生信息管理系统
数据结构课程设计论文--学生信息管理系统 1.学生成绩分析问题 (1)问题描述.录入并保存一个班级学生多门课程的成绩,并对成绩进行分析. (2)基本要求.a)通过键盘输入各学生的多门课程的成绩,建立相 ...
- MySQL课程设计——简易学生信息管理系统
学生信息管理系统 一 分析 1.1 系统需求分析 1.1.1 业务分析 1.1.2 分析系统 1.2 功能模块 1.2.1 学生模块 1.2.2 教师模块 二 构建模型 2.1 概念模型:ERP模型 ...
- c语言程序设计课程设计学生信息管理系统,C语言程序设计课程设计报告----学生信息管理系统.doc...
河南理工大学计算机学院 <C语言程序设计>课程设计报告 题目: 学生信息管理系统 专业: 计算机科学与技术 班级: 计算机XX班 学号: 311009033232 姓名: ***** 日期 ...
- Java课程设计【学生信息管理系统】
课程设计目录 一.问题描述 二.基本要求 三.需求分析 四.概要设计 1.类之间的调用关系 2.学生信息模块 3.系统管理模块 4.详细设计 ①主程序LoginGUI的代码 ②程序View的代码 ③程 ...
- c语言课程设计报告15页左右,C语言课程设计报告——学生信息管理系统(15页)-原创力文档...
C语言程序设计 课程设计报告 设计题目:学生信息管理系统 专 业 电子信息工程 班 级 学 生 指导教师 年 学期 设计任务: C语言课程设计任务书及指导书 5 题目:学生信息管理系统 功能:学生信息 ...
- 数据结构与算法 课程设计报告——学生信息管理系统
一.概述 1.开发背景 使用计算机对学生信息进行管理,拥有手工管理所无法比拟的优点.例如:检索迅速.查找方便.可靠性高.存储量大.成本低等.这些优点能够极大地提高学生信息的效率,也是管理科学化.正规化 ...
- Python课程设计:学生成绩管理系统(附源代码)
版权声明:本文为CSDN博主「大格子嘞」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明.原文链接: https://blog.csdn.net/qq_43971504 ...
- 基于MFC——C++课程设计《学生信息管理系统》
文章目录 前言 一.系统设计功能: 二.对应板块 1.登陆板块 2.系统主页面相应功能 总结 前言 随笔之作,希望通过写文章的方式加深自己对于C++知识架构和设计过程中出现的一些Bug的印象,如有错误 ...
最新文章
- 机器学习之XGBoosting
- Android Studio 使用感受 错误解决
- android TextView实现滚动显示效果
- 糊涂虫 php,糊涂虫 hat folgende Bedeutung
- 使用VS2015远程GDB调试
- Spring 整合 RocketMQ
- layuiadmin上手好难_新手如何快速上手自媒体赚钱?送你4个好建议!记得收藏
- tomcat如何查找请求资源的?
- 本地邮件系统的安装及配置
- [转载]提升进程权限-OpenProcessToken等函数的用法
- css技巧---电子表体字体引入
- API函数的调用过程
- RIP总结(转自鸿鹄论坛)
- 机器学习中的 Shapley 值怎么理解?
- bert代码解读2之模型transformer的解读
- 一般将来时语法课教案_初中英语语法课教案设计
- DOSBox 0.74 汇编 out of memery test.asm(2):out of memory
- Congfu Xu's HomePage
- java通过itext方法往pdf中插入图片(交互式pdf插入图片无法显示)
- 唯品会财报:一面骄阳,一面寒霜