存储学生信息
stu_mesall = {undefined
"s001": {"sno": "s001", "name": "张三", "age": 23, "sex": "男", "Python": 45},
"s002": {"sno": "s002", "name": "李思", "age": 18, "sex": "女", "Python": 87}
}
with open("学生信息.txt", mode="w", encoding="utf-8") as stu_mesalls:
stu_mesalls.write(str(stu_mesall))
stu_mesall = {}
显示所有学生信息
def show_mes():
print("""
欢迎使用【不染学员管理信息系统】V2.0
1. 显示所有学生信息
2. 新建学生信息
3. 查询学生信息
4. 修改学生信息
5. 删除学生信息
6. 选择显示功能
7. 退出系统
""")
显示所有学生信息
def show_all():
if os.path.exists("学生信息.txt"):
with open("学生信息.txt", mode="r", encoding="utf-8") as file:
ret = file.read()
global stu_mesall
stu_mesall = eval(ret)
for item in stu_mesall.values():
print(f"学号:{item['sno']} | 姓名:{item['name']} | 年龄:{item['age']} | 性别:{item['sex']} | Python成绩:{item['Python']}")