一篇文章教你用Python实现一个学生管理系统
作者:玫瑰花店 时间:2022-01-22 16:25:05
片头
Python看了差不多三四天吧,基本上给基础看差不多了。写个管理系统吧,后续不出意外SQL、文件存储版本都会更。
学习Python感想:
人生苦短,我用Python
人生苦短,我用Python
人生苦短,我用Python
人生苦短,我用Python
Python实在太爽了
源码:
使用Python3
'''
学生成绩管理系统
时间:2021.9.9
作者:sunbeam
'''
import time
import os
student_list = [] #定义一个列表类型全局变量
'''
列表里面存储所有学生信息,列表里面每个元素是一个字典,字典里面存放每一个学生的个人信息,存储结构如下
[(姓名1,年龄1,学号1,手机号码1),(姓名2,年龄2,学号2,手机号码2)......]
'''
def time_day():
print()
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())))
#主菜单界面
def std_menu():
print("--------欢迎来到sunbeam的第一个python学生管理系统--------")
print(" 1、添加学生信息 2、删除学生信息 ")
print(" 3、查找学生信息 4、修改学生信息 ")
print(" 5、显示所有学生 6、退出系统 ")
num=int(input("根据需求请输入对应的序号:"))
return num
#添加学生信息
def std_add():
while 1:
std_name = input("请输入要添加的学生的姓名:")
std_old = input("请输入要添加的学生的年龄:")
std_id = input("请输入要添加的学生的学号:")
std_tel = input("请输入要添加的学生的电话号码:")
global student_list
# 判断学生是否已存在,如果姓名和学号都重复说明学生存在
for i in student_list:
if (i['name'] == std_name) and (i['id'] == std_id):
print("此学生信息已存在")
return
#如果学生信息不存在则添加学生信息
std_message = {} #创建一个空的字典
std_message['name']=std_name
std_message['old']=std_old
std_message['id']=std_id
std_message['tel']=std_tel
student_list.append(std_message)
text=input("是否继续添加:YES or NO")
if text=='NO':
os.system('cls')
break
else:
os.system('cls')
continue
#查找学生信息
def std_find():
flag=0
while 1:
find_name = input("请输入你要查询的学生的姓名:")
global student_list
for i in student_list:
if (i['name'] == find_name):
print("查询到如下学生:")
print("-------------------")
print(f"姓名:{i['name']}")
print(f"年龄:{i['old']}")
print(f"学号:{i['id']}")
print(f"电话:{i['tel']}")
print("-------------------")
flag=1
if flag==0:
print("查无此人")
lk=input("是否继续查找:YES or NO")
if lk=="NO":
os.system('cls')
break
else:
os.system('cls')
continue
#修改学生信息
def std_modify():
while 1:
find_name=input("请输入要修改的学生的学号:")
global student_list
for i in student_list:
if (i['id']==find_name):
print("你要修改的学生信息如下:")
print("-------------------")
print(f"姓名:{i['name']}")
print(f"年龄:{i['old']}")
print(f"学号:{i['id']}")
print(f"电话:{i['tel']}")
print('-----------------')
while 1:
print(" 1、修改学生姓名 2、修改学生年龄 ")
print(" 3、修改学生学号 4、修改学生电话 ")
modify_num = int(input('请输入要修改的项目序号:'))
if modify_num==1:
modify_name=input("请输入要修改的学生的姓名:")
i['name']=modify_name
elif modify_num==2:
modify_old=input("请输入要修改的学生的年龄:")
i['old']=modify_old
elif modify_num==3:
modify_id=input("请输入要修改的学生的学号:")
i['id']=modify_id
else:
modify_tel=input("请输入要修改的学的生电话:")
i['tel']=modify_tel
print("是否继续修改当前学生信息:YES or NO")
print('---------------------')
modify_flag=input()
if modify_flag=="NO":
print("-----修改完成-----")
break
else:
continue
break
print("是否继续使用修改模块功能:YES or NO")
lag=input()
if lag=="YES":
os.system('cls')
continue
else:
os.system('cls')
break
#显示所有学生信息
def std_all():
global student_list
print('姓名\t年龄\t学号\t电话')
for i in student_list:
print(f"{i['name']}\t{i['old']}\t{i['id']}\t{i['tel']}")
#删除函数
def std_delete():
global student_list
while 1:
print("-----------------")
del_num = input("请输入要删除的学生的学号:")
for i in student_list:
if (i['id'] == del_num):
student_list.remove(i)
print("删除成功")
break
else:
print("查无此人")
del_exit=input("是否退出:YES or NO")
print("-----------------")
if del_exit=='YES':
os.system('cls')
break
else:
os.system('cls')
continue
while 1:
time_day()
user_num=std_menu()
if user_num==1:
std_add()
elif user_num==2:
std_delete()
elif user_num==3:
std_find()
elif user_num==4:
std_modify()
elif user_num==5:
std_all()
elif user_num==6:
os.system('cls')
exit_flag=input("是否退出:YES or NO")
if exit_flag=='YES':
print("感谢使用,bey-bey")
break
else:
continue
else:
print("输入无用序号,请输入菜单前序号。")
来源:https://blog.csdn.net/qq_42695024/article/details/120204214
标签:Python,管理系统
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
MySQL中数据表操作详解
2008-12-29 13:50:00
《写给大家看的设计书》阅读笔记之亲密性原则
2009-07-08 20:02:00
![](https://img.aspxhome.com/file/UploadPic/20097/8/qmx_1-99s.jpg)
Python实现简单的"导弹" 自动追踪原理解析
2021-04-15 05:48:27
![](https://img.aspxhome.com/file/2023/9/110549_0s.png)
关于IDEA git 只有Commit没有Push的问题
2023-07-20 02:26:58
![](https://img.aspxhome.com/file/2023/7/63437_0s.png)
常用的数据库备份类型有哪些?
2009-11-01 13:02:00
使用Django xadmin 实现修改时间选择器为不可输入状态
2023-11-19 12:12:06
![](https://img.aspxhome.com/file/2023/6/87716_0s.jpg)
pytorch 如何把图像数据集进行划分成train,test和val
2023-12-26 15:28:10
![](https://img.aspxhome.com/file/2023/4/72124_0s.png)
python定向爬取淘宝商品价格
2023-10-03 23:33:12
Python实现随机从图像中获取多个patch
2021-09-19 13:39:56
![](https://img.aspxhome.com/file/2023/0/97120_0s.jpg)
asp中如何过滤到单引号
2009-07-05 18:38:00
python3 实现函数写文件路径的正确方法
2023-12-09 11:38:51
Python Pandas 删除列操作
2023-12-17 22:03:53
Python可视化学习之matplotlib内置单颜色
2021-07-27 06:43:46
![](https://img.aspxhome.com/file/2023/9/89309_0s.jpg)
python实现逢七拍腿小游戏的思路详解
2021-02-28 23:44:29
![](https://img.aspxhome.com/file/2023/0/86320_0s.png)
完美解决Python2操作中文名文件乱码的问题
2022-12-12 11:29:46
![](https://img.aspxhome.com/file/2023/2/90832_0s.jpg)
GDAL 矢量属性数据修改方式(python)
2021-01-30 20:53:28
![](https://img.aspxhome.com/file/2023/7/78537_0s.jpg)
python反编译教程之2048小游戏实例
2023-07-24 08:04:47
![](https://img.aspxhome.com/file/2023/5/71405_0s.png)
解决win7操作系统Python3.7.1安装后启动提示缺少.dll文件问题
2021-08-09 00:56:29
![](https://img.aspxhome.com/file/2023/3/112743_0s.png)
再谈float菜单局中
2009-12-21 19:57:00
解决Python列表字符不区分大小写的问题
2022-09-10 20:43:52