学生成绩管理系统(Python学习)
一个简单得学生成绩管理系统,记录自己学习python得历程,学习改变命运!
import json
while True:
print("命令0:退出系统!")
print("命令1:填入学生成绩:")
print("命令2:查看学生成绩:")
order = input("请输入你要操作的命令:")
if order == "0":
print("退出系统成功!")
break
elif order == "1":
while True:
dict = {}
name = input("请输入姓名:")
classroom = input("请输入班级:")
yuwen = input("请输入语文成绩:")
shuxue = input("请输入数学成绩:")
yingyu = input("请输入英语成绩:")
dict["姓名"] = name
dict["班级"] = classroom
dict["语文成绩"] = yuwen
dict["数学成绩"] = shuxue
dict["英语成绩"] = yingyu
json_dict = str(dict)
with open("students.txt", "a") as f:
f.write(json_dict + "\n")
result = input("是否继续录入学生成绩(y/n):")
if result == "y":
try:
with open("students.txt", "a") as f:
f.write(json_dict + "\n")
print("填写信息成功")
except Exception as e:
with open("logger.txt", "a") as f:
f.write("报错信息详情:", + e)
print("填写失败,请重新填写")
elif result == "n":
break
else:
print("操作命令有误,请重新输入")
elif order == "2":
with open("students.txt", "r") as f:
print(f.read())
else:
print("命令输入有误,请重新输入")
本文地址:https://blog.csdn.net/weixin_46503909/article/details/107304890
上一篇: Python列表推导式