使用python完成超级基础的学生管理系统,供大家参考,具体内容如下
说明:
1、本学生管理系统非常非常简易,只有增,显,查,删,改功能,对于Python新手容易看懂上手。
2、信息的存储只使用了字典和列表。
3、不喜勿喷。
代码:
1、主循环框架
while True:
print(info_str)
action = input("请输入想要进行的操作:")
if action == '0':
print("再见。")
break
elif action == '1':
print("新建学生信息")
elif action == '2':
print("显示全部学生")
elif action == '3':
print("查询学生信息")
elif action == '4':
print("删除学生信息")
elif action == '5':
print("修改学生信息")
else:
print("你的输入有错误,请重新输入。")
2、源代码
info_str = """
*************************
1.新建学生信息
2.显示全部学生
3.查询学生信息
4.删除学生信息
5.修改学生信息
0.退出系统
*************************
"""
"""姓名、语文成绩、数学成绩、英语成绩、总分"""
students = [
{'Name':'张大炮','Chinese':'95','Math':'65','English':'65','Score':'215'},
{'Name':'张益达','Chinese':'65','Math':'95','English':'65','Score':'215'},
{'Name':'Snack','Chinese':'65','Math':'65','English':'95','Score':'215'},
]
while True:
""""程序主循环"""
print(info_str)
action = input("请输入想要进行的操作:")
if action == '0':
"""结束条件"""
print("撒由那拉。")
break
elif action == '1':
print("新建学生信息")
Name = input("请输入名字:")
Chinese = input("请输入语文成绩:")
Math = input("请输入数学成绩:")
English = input("请输入英语成绩:")
Score = int(Chinese) + int(Math) + int(English)
student={
'Name':Name,
'Chinese':Chinese,
'Math':Math,
'English':English,
'Score':Score
}
students.append(student)
elif action == '2':
print("显示全部学生")
for student in students:
print(student)
elif action == '3':
print("查询学生信息")
Name = input('请输入需要查询的名字:')
for student in students:
if student['Name'] == Name:
print(student)
else:
print("{}信息不存在".format(Name))
elif action == '4':
print("删除学生信息")
Name = input("请输入需要删除的名字:")
for student in students:
if student['Name'] == Name:
students.remove(student)
break
else:
print("{}信息不存在".format(Name))
elif action == '5':
print("修改学生信息")
Name = input("请输入需要修改的名字:")
for student in students:
if student['Name'] == Name:
student['Name'] = input("请输入名字:")
student['Chinese'] = input("请输入语文成绩:")
student['Math'] = input("请输入数学成绩:")
student['English'] = input("请输入英语成绩:")
student['Score'] = int(student['Chinese']) + int(student['Math']) + int(student['English'])
else:
print("{}信息不存在".format(Name))
else:
print("你的输入有错误,请重新输入。")
总结
1、代码框架简洁明了,添加功能只需要在主循环中增加即可。
2、超级基础,不喜勿喷。
关于“用Python怎样写个基础的学生管理系统”的内容今天就到这,感谢各位的阅读,大家可以动手实际看看,对大家加深理解更有帮助哦。如果想了解更多相关内容的文章,关注我们,群英网络小编每天都会为大家更新不同的知识。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
长按识别二维码并关注微信
更方便到期提醒、手机管理