如何搭建自己的学生管理系统(相关视频哔哩哔哩诣秋):
主体程序(附源代码):
str_message = """
**************************************************
欢迎使用【学生信息管理系统】V1.0
请选择你想要进行的操作
1. 新建学生信息
2. 显示全部信息
3. 查询学生信息
4. 删除学生信息
5. 修改学生信息
0. 退出系统
**************************************************
"""
# students = [
# {'name': '张三', 'chinese': '65', 'math': '65', 'english': '65', 'total': 195},
# {'name': '李四', 'chinese': '65', 'math': '65', 'english': '65', 'total': 195},
# {'name': '王五', 'chinese': '65', 'math': '65', 'english': '65', 'total': 195}
# ]
import json
with open('students.json', mode='r', encoding='utf-8') as f:
data = f.read()
students = json.loads(data)
while True:
print(str_message)
action = input('请输入你需要的操作:')
# pass python中的空语句, 不做任何事情
if action == '1':
print('1. 新建学生信息')
# 输入学生信息
name = input('请输入名字:')
chinese = input('请输入语文成绩:')
math = input('请输入数学成绩:')
english = input('请输入英语成绩:')
total = int(chinese) + int(math) + int(english)
# print(total)
d = {
'name': name,
'chinese': chinese,
'math': math,
'english': english,
'total': total
}
# students = []
students.append(d)
elif action == '2':
print('2. 显示全部信息')
print('姓名\t\t语文\t\t数学\t\t英语\t\t总分')
for stu in students:
# print(stu)
# 第一种
# print(stu[