1
Python 学生管理系统
作者:漫步桔田
- 2023-02-25 北京
本文字数:23445 字
阅读完需:约 77 分钟
一、系统要求
编写学生管理系统程序,应具备以下几点功能:
1.用户认证系统用户分为学生、教师、管理员三个角色,系统可根据不同用户角色权限进入不同界面,所有用户角色需要通过身份验证才能登录系统进行操作。
2.学生登录主要实现学生登录系统可查看本人基本信息、考试成绩、修改密码。
3.教师登录主要实现教师登录系统可查看本人基本信息、学生信息、学生成绩、修改密码。
4.管理登录主要实现管理员登录系统可查看本人基本信息、修改本人信息、查询老师信息、修改老师信息、录入老师信息、删除老师信息、查询学生信息、修改学生信息、录入学生信息、删除学生信息、查询考试成绩、修改考试成绩、录入考试成绩、删除考试成绩、修改登录密码。
5.退出系统所以角色操作完成可退出系统登录。
二、用户信息
1.管理信息
{
"123456": [
"111111",
"漫漫",
"男",
32,
"12312300001"
],
"123452": [
"111111",
"桔桔",
"女",
27,
"12312300002"
],
"123453": [
"111111",
"可可",
"女",
25,
"12312300003"
]
}
复制代码
2.教师信息
{
"123001": [
"111111",
"闻闻",
"女",
27,
"12300000001",
{
"Python一年级": [
"Python一班",
"Python二班"
]
}
],
"123002": [
"111111",
"雯雯",
"女",
25,
"12300000002",
{
"Python二年级": [
"Python一班",
"Python二班"
]
}
],
"123003": [
"111111",
"贝贝",
"女",
28,
"12300000003",
{
"Java一年级": [
"Java一班",
"Java二班"
],
"Java二年级": [
"Java一班",
"Java二班"
]
}
]
}
复制代码
3.学生信息
{
"210101": [
"121212",
"Python",
"Python一年级",
"Python一班",
"路飞",
"男",
21,
"2000-01-01",
"13901230001"
],
"210102": [
"111111",
"Python",
"Python一年级",
"Python一班",
"女帝",
"女",
18,
"2003-02-01",
"13901230002"
],
"210103": [
"111111",
"Python",
"Python一年级",
"Python二班",
"小新",
"男",
21,
"2000-02-14",
"13901230003"
],
"210104": [
"111111",
"Python",
"Python一年级",
"Python二班",
"妮妮",
"女",
18,
"2003-04-15",
"13901230004"
],
"210105": [
"111111",
"Python",
"Python二年级",
"Python一班",
"大熊",
"男",
21,
"2000-05-01",
"13901230005"
],
"210106": [
"111111",
"Python",
"Python二年级",
"Python一班",
"静香",
"女",
18,
"2003-06-01",
"13901230006"
],
"210107": [
"111111",
"Python",
"Python二年级",
"Python二班",
"新一",
"男",
21,
"2000-06-01",
"13901230007"
],
"210108": [
"111111",
"Python",
"Python二年级",
"Python二班",
"小兰",
"女",
18,
"2003-07-01",
"13901230008"
],
"210201": [
"111111",
"Java",
"Java一年级",
"Java一班",
"鸣人",
"男",
21,
"2000-01-01",
"13911230001"
],
"210202": [
"111111",
"Java",
"Java一年级",
"Java一班",
"雏田",
"女",
18,
"2003-02-01",
"13911230002"
],
"210203": [
"111111",
"Java",
"Java一年级",
"Java二班",
"唐三",
"男",
21,
"2000-03-01",
"13911230003"
],
"210204": [
"111111",
"Java",
"Java一年级",
"Java二班",
"小舞",
"女",
18,
"2003-04-15",
"13911230004"
],
"210205": [
"111111",
"Java",
"Java二年级",
"Java一班",
"萧炎",
"男",
21,
"2000-03-14",
"13911230005"
],
"210206": [
"111111",
"Java",
"Java二年级",
"Java一班",
"薰儿",
"女",
18,
"2003-06-06",
"13911230006"
],
"210207": [
"111111",
"Java",
"Java二年级",
"Java二班",
"石昊",
"男",
18,
"2000-05-06",
"13911230007"
],
"210208": [
"111111",
"Java",
"Java二年级",
"Java二班",
"云曦",
"女",
18,
"2003-08-08",
"13911230008"
]
}
复制代码
4.考试成绩
{
"210101": {
"语文": 88,
"数学": 87,
"英语": 90
},
"210102": {
"语文": 81,
"数学": 85,
"英语": 86
},
"210103": {
"语文": 83,
"数学": 81,
"英语": 91
},
"210104": {
"语文": 85,
"数学": 82,
"英语": 90
},
"210105": {
"语文": 89,
"数学": 86,
"英语": 93
},
"210106": {
"语文": 81,
"数学": 87,
"英语": 95
},
"210107": {
"语文": 90,
"数学": 86,
"英语": 90
},
"210108": {
"语文": 92,
"数学": 81,
"英语": 91
},
"210201": {
"语文": 81,
"数学": 96,
"英语": 90
},
"210202": {
"语文": 83,
"数学": 86,
"英语": 92
},
"210203": {
"语文": 88,
"数学": 81,
"英语": 89
},
"210204": {
"语文": 85,
"数学": 81,
"英语": 92
},
"210205": {
"语文": 82,
"数学": 83,
"英语": 95
},
"210206": {
"语文": 86,
"数学": 99,
"英语": 91
},
"210207": {
"语文": 85,
"数学": 78,
"英语": 95
},
"210208": {
"语文": 82,
"数学": 81,
"英语": 90
}
}
复制代码
三、管理系统
1.管理系统
from students import student_login
from teacher import teacher_login
from administrator import administrator_login
import time
import json
open_administrator = open('administrator.json', 'r', encoding='utf-8')
administrator = json.loads(open_administrator.read())
open_teacher = open('teacher.json', 'r', encoding='utf-8')
teacher = json.loads(open_teacher.read())
open_student = open('student.json', 'r', encoding='utf-8')
student = json.loads(open_student.read())
open_results = open('results.json', 'r', encoding='utf-8')
results = json.loads(open_results.read())
while True:
permissions = input('请您选择用户权限(1.学生登录 2.教师登录 3. 管理登录 4.退出系统):')
if permissions == '1':
student_login(student, results)
elif permissions == '2':
teacher_login(teacher, student, results)
elif permissions == '3':
administrator_login(administrator, teacher, student, results)
elif permissions == '4':
break
save_administrator = open('administrator.json', 'w', encoding='utf-8')
json.dump(administrator, save_administrator, ensure_ascii=False, indent=4)
save_teacher = open('teacher.json', 'w', encoding='utf-8')
json.dump(teacher, save_teacher, ensure_ascii=False, indent=4)
save_student = open('student.json', 'w', encoding='utf-8')
json.dump(student, save_student, ensure_ascii=False, indent=4)
save_results = open('results.json', 'w', encoding='utf-8')
json.dump(results, save_results, ensure_ascii=False, indent=4)
复制代码
2.学生登录
import time
def student_login(x, y):
while True:
login_operation = input('请您选择登录操作(1.登录系统 2.找回密码 3.退出系统):')
if login_operation == '1':
account = input('请您输入学生证号:')
password = input('请您输入登录密码:')
if account in x and x[account][0] == password:
time.sleep(0.5)
print('密码正确,登录成功')
while True:
query = input('请您选择操作选项(1.查询个人信息 2.查询考试成绩 3.修改登录密码 4.退出查询):')
if query == '1':
print('*' * 5 + '个人信息' + '*' * 5)
print('专业:{}'.format(x[account][1]))
print('年级:{}'.format(x[account][2]))
print('班级:{}'.format(x[account][3]))
print('学号:{}'.format(account))
print('姓名:{}'.format(x[account][4]))
print('性别:{}'.format(x[account][5]))
print('年龄:{}'.format(x[account][6]))
print('生日:{}'.format(x[account][7]))
print('电话:{}'.format(x[account][8]))
print('*' * 15)
time.sleep(0.5)
elif query == '2':
print('*' * 5 + '考试成绩' + '*' * 5)
print('语文:{}'.format(y[account]['语文']))
print('数学:{}'.format(y[account]['数学']))
print('英语:{}'.format(y[account]['英语']))
print('*' * 16)
time.sleep(0.5)
elif query == '3':
while True:
reserved = input('请您输入预留手机号码:')
if reserved == x[account][8]:
new_password = input('请您输入新密码:')
x[account][0] = new_password
time.sleep(0.5)
print('密码修改成功!新密码:{}'.format(new_password))
break
else:
print('号码错误,请您核实!')
modify = input('是否继续修改(1.继续 2.退出):')
if modify == '2':
break
elif query == '4':
break
elif account in x and x[account][0] != password:
print('密码错误,请核实密码!')
else:
print('不好意思,您输入的学号不存在')
elif login_operation == '2':
retrieve_password = input('是否需要找回密码(1.需要 2.取消):')
if retrieve_password == '1':
while True:
student_id = input('请您输入学生证号:')
if student_id in x:
break
else:
print('学号错误,请您核实!')
while True:
phone = input('请您输入预留手机号码:')
if x[student_id][8] == phone:
break
else:
print('号码错误,请您核实!')
while True:
first_input = input('请您输入新密码:')
second_input = input('请再次输入密码:')
if first_input == second_input:
x[student_id][0] = first_input
time.sleep(0.5)
print('密码找回成功,请重新登录!')
break
else:
print('两次密码不一致,请您仔细核对!')
elif login_operation == '3':
break
复制代码
3.教师登录
import time
def teacher_login(x, y, z):
while True:
login_operation = input('请您选择登录操作(1.登录系统 2.找回密码 3.退出系统):')
if login_operation == '1':
account = input('请您输入员工号码:')
password = input('请您输入登录密码:')
if account in x and x[account][0] == password:
time.sleep(0.5)
print('密码正确,登录成功')
while True:
query = input('请您选择操作选项(1.查询本人信息 2.查询学生信息 3.查询考试成绩 4.修改登录密码 5.退出查询):')
if query == '1':
print('*' * 10 + '个人信息' + '*' * 10)
print('教师工号:{}'.format(account))
print('教师姓名:{}'.format(x[account][1]))
print('教师性别:{}'.format(x[account][2]))
print('教师年龄:{}'.format(x[account][3]))
print('教师电话:{}'.format(x[account][4]))
for m, n in x[account][5].items():
print('授课年级:{}'.format(m))
print('授课班级:{}'.format(' '.join(n)))
print('*' * 27)
time.sleep(0.5)
elif query == '2':
while True:
entry = input('是否继续查询操作(1.继续 2.退出):')
if entry == '1':
way = input('请您选择查询方式(1.查询个人 2.查询全部):')
if way == '1':
student_id = input('请您输入需要查询同学的学号:')
if y[student_id][2] in x[account][5]:
print('*' * 5 + '学生信息' + '*' * 5)
print('学号:{}'.format(student_id))
print('姓名:{}'.format(y[student_id][4]))
print('性别:{}'.format(y[student_id][5]))
print('年龄:{}'.format(y[student_id][6]))
print('生日:{}'.format(y[student_id][7]))
print('电话:{}'.format(y[student_id][8]))
print('*' * 15)
time.sleep(0.5)
else:
print('该同学不在您授课班级内!')
elif way == '2':
print('*' * 30 + '学生信息' + '*' * 30)
for i in y:
for m, n in x[account][5].items():
if y[i][2] == m and y[i][3] in n:
print('学号:{}、姓名:{}、性别:{}、年龄:{}、生日:{}、电话:{}'.
format(i, y[i][4], y[i][5], y[i][6], y[i][7], y[i][8]))
print('*' * 67)
time.sleep(0.5)
elif entry == '2':
break
elif query == '3':
while True:
entry = input('是否继续查询操作(1.继续 2.退出):')
if entry == '1':
way = input('请您选择查询方式(1.查询个人 2.查询全部):')
if way == '1':
student_id = input('请您输入需要查询同学的学号:')
if y[student_id][2] in x[account][5]:
print('*' * 3 + '考试成绩' + '*' * 3)
print('学号:{}'.format(student_id))
print('姓名:{}'.format(y[student_id][4]))
print('语文:{}'.format(z[student_id]['语文']))
print('数学:{}'.format(z[student_id]['数学']))
print('英语:{}'.format(z[student_id]['英语']))
print('*' * 10)
time.sleep(0.5)
else:
print('该同学不在您授课班级内!')
elif way == '2':
print('*' * 16 + '学生考试成绩' + '*' * 16)
for i in y:
for m, n in x[account][5].items():
if y[i][2] == m and y[i][3] in n:
print('学号:{}、姓名:{}、语文:{}、数学:{}、英语:{}'.
format(i, y[i][4], z[i]['语文'], z[i]['数学'], z[i]['英语']))
print('*' * 42)
time.sleep(0.5)
elif entry == '2':
break
elif query == '4':
while True:
reserved = input('请您输入预留手机号码:')
if reserved == x[account][4]:
new_password = input('请您输入新密码:')
x[account][0] = new_password
time.sleep(0.5)
print('密码修改成功!新密码:{}'.format(new_password))
break
else:
print('号码错误,请您核实!')
modify = input('是否继续修改(1.继续 2.退出):')
if modify == '2':
break
elif query == '5':
break
elif account in x and x[account][0] != password:
print('密码错误,请核实密码!')
else:
print('不好意思,工号不存在!')
elif login_operation == '2':
retrieve_password = input('是否需要找回密码(1.需要 2.取消):')
if retrieve_password == '1':
while True:
teacher_id = input('请您输入教师工号:')
if teacher_id in x:
break
else:
print('工号错误,请您核实!')
while True:
phone = input('请您输入预留手机号码:')
if x[teacher_id][4] == phone:
break
else:
print('号码错误,请您核实!')
while True:
first_input = input('请您输入新密码:')
second_input = input('请再次输入密码:')
if first_input == second_input:
x[teacher_id][0] = first_input
time.sleep(0.5)
print('密码找回成功,请您重新登录!')
break
else:
print('两次密码不同,请您仔细核对!')
elif login_operation == '3':
break
复制代码
4.管理登录
import time
options = '''********************************
1.查询本人信息 2.修改本人信息
3.查询老师信息 4.修改老师信息
5.录入老师信息 6.删除老师信息
7.查询学生信息 8.修改学生信息
9.录入学生信息 10.删除学生信息
11.查询考试成绩 12.修改考试成绩
13.录入考试成绩 14.删除考试成绩
15.修改登录密码 16.退出系统登录
********************************'''
def administrator_login(a, b, c, d):
while True:
login_operation = input('请您选择登录操作(1.登录系统 2.找回密码 3.退出系统):')
if login_operation == '1':
account = input('请您输入管理账号:')
password = input('请您输入登录密码:')
if account in a and a[account][0] == password:
time.sleep(0.5)
print('密码正确,登录成功')
while True:
print(options)
query = input('请您选择操作选项:')
if query == '1':
print('*' * 6 + '个人信息' + '*' * 6)
print('管理账号:{}'.format(account))
print('管理姓名:{}'.format(a[account][1]))
print('管理性别:{}'.format(a[account][2]))
print('管理年龄:{}'.format(a[account][3]))
print('管理电话:{}'.format(a[account][4]))
print('*' * 18)
time.sleep(0.5)
elif query == '2':
print('*' * 23 + '个人信息' + '*' * 23)
print('账号:{}、姓名:{}、性别:{}、年龄:{}、电话:{}'.
format(account, a[account][1], a[account][2], a[account][3], a[account][4]))
print('*' * 52)
while True:
personal_change = input('请您选择修改选项(1.姓名 2.性别 3.年龄 4.电话 5.退出):')
if personal_change == '1':
name = input('请您输入姓名:')
a[account][1] = name
elif personal_change == '2':
gender = input('请您输入性别:')
a[account][2] = gender
elif personal_change == '3':
age = input('请您输入年龄:')
a[account][3] = age
elif personal_change == '4':
phone = input('请您输入电话:')
a[account][4] = phone
elif personal_change == '5':
break
print('*' * 23 + '个人信息' + '*' * 23)
print('账号:{}、姓名:{}、性别:{}、年龄:{}、电话:{}'.
format(account, a[account][1], a[account][2], a[account][3], a[account][4]))
print('*' * 52)
time.sleep(0.5)
elif query == '3':
while True:
way = input('请您选择查询操作(1.查询个人 2.查询全部 3.退出查询):')
if way == '1':
teacher_id = input('请您输入需要查询老师的工号:')
if teacher_id in b:
print('*' * 11 + '教师信息' + '*' * 11)
print('工号:{}'.format(teacher_id))
print('姓名:{}'.format(b[teacher_id][1]))
print('性别:{}'.format(b[teacher_id][2]))
print('年龄:{}'.format(b[teacher_id][3]))
print('电话:{}'.format(b[teacher_id][4]))
for m, n in b[teacher_id][5].items():
print('授课年级:{}'.format(m))
print('授课班级:{}'.format(' '.join(n)))
print('*' * 27)
time.sleep(0.5)
else:
print('教师工号错误,请您核实!')
elif way == '2':
print('*' * 50 + '教师信息' + '*' * 50)
for i in b:
for m, n in b[i][5].items():
print('工号:{}、姓名:{}、性别:{}、年龄:{}、电话:{}、授课年级:{}、授课班级:{}'.
format(i, b[i][1], b[i][2], b[i][3], b[i][4], m, ' '.join(n)))
print('*' * 106)
time.sleep(0.5)
elif way == '3':
break
elif query == '4':
teacher_id = input('请您输入需要修改老师的工号:')
if teacher_id in b:
print('*' * 50 + '教师信息' + '*' * 50)
for m, n in b[teacher_id][5].items():
print('工号:{}、姓名:{}、性别:{}、年龄:{}、电话:{}、授课年级:{}、授课班级:{}'.
format(teacher_id, b[teacher_id][1], b[teacher_id][2],
b[teacher_id][3], b[teacher_id][4], m, ' '.join(n)))
print('*' * 106)
while True:
teacher_change = input('请您选择修改选项(1.姓名 2.性别 3.年龄 4.电话 5.授课年级(班级) 6.退出):')
if teacher_change == '1':
name = input('请您输入姓名:')
b[teacher_id][1] = name
elif teacher_change == '2':
gender = input('请您输入性别:')
b[teacher_id][2] = gender
elif teacher_change == '3':
age = input('请您输入年龄:')
b[teacher_id][3] = age
elif teacher_change == '4':
phone = input('请您输入电话:')
b[teacher_id][4] = phone
elif teacher_change == '5':
teacher_options = input('请您选择操作类型(1.增加班级 2.删除班级 3.退出操作):')
while True:
if teacher_options == '1':
add_grade = input('请您输入增加年级:').capitalize()
add_class = input('请您输入增加班级:').capitalize()
if add_grade in b[teacher_id][5] and add_class in b[teacher_id][5][
add_grade]:
print('您输入的年级和班级已存在')
elif add_grade in b[teacher_id][5] and add_class not in b[teacher_id][5][
add_grade]:
b[teacher_id][5][add_grade].append(add_class)
print('信息添加成功')
break
else:
b[teacher_id][5][add_grade] = [add_class]
print('信息添加成功')
break
elif teacher_options == '2':
choose = input('是否继续操作(1.继续 2.退出)')
if choose == '1':
delete_grade = input('请您输入删除年级:').capitalize()
delete_class = input('请您输入删除班级:').capitalize()
if delete_grade in b[teacher_id][5]:
if delete_class in b[teacher_id][5][delete_grade]:
b[teacher_id][5][delete_grade].remove(delete_class)
print('信息删除成功')
break
elif b[teacher_id][5][delete_grade] == []:
del b[teacher_id][5][delete_grade]
print('信息删除成功')
break
else:
print('您输入的班级不存在')
else:
print('您输入的年级不存在')
elif choose == '2':
break
elif teacher_options == '3':
break
elif teacher_change == '6':
break
print('*' * 50 + '教师信息' + '*' * 50)
if b[teacher_id][5] == {}:
print('工号:{0}、姓名:{1}、性别:{2}、年龄:{3}、电话:{4}、授课年级:{5}、授课班级:{5}'.
format(teacher_id, b[teacher_id][1], b[teacher_id][2],
b[teacher_id][3], b[teacher_id][4], '无'))
else:
for m, n in b[teacher_id][5].items():
print('工号:{0}、姓名:{1}、性别:{2}、年龄:{3}、电话:{4}、授课年级:{5}、授课班级:{6}'.
format(teacher_id, b[teacher_id][1], b[teacher_id][2],
b[teacher_id][3], b[teacher_id][4], m, ' '.join(n)))
print('*' * 106)
else:
print('教师工号错误,请您核实!')
elif query == '5':
while True:
choose = input('是否继续操作(1.继续 2.退出)')
if choose == '1':
teacher_id = input('请您输入教师工号:')
if teacher_id in b:
print('该教师工号已存在')
else:
b[teacher_id] = ['', '', '', '', '', '']
b[teacher_id][0] = input('请您输入登录密码:')
b[teacher_id][1] = input('请您输入教师姓名:')
b[teacher_id][2] = input('请您输入教师性别:')
b[teacher_id][3] = input('请您输入教师年龄:')
b[teacher_id][4] = input('请您输入教师电话:')
teacher_grade = input('请您输入教师授课年级:')
teacher_class = input('请您输入教师授课班级(多个班级请用英文,隔开输入):')
b[teacher_id][5] = {teacher_grade: [teacher_class]}
print('教师信息录入成功')
time.sleep(0.5)
print('*' * 50 + '教师信息' + '*' * 50)
for m, n in b[teacher_id][5].items():
print('工号:{}、姓名:{}、性别:{}、年龄:{}、电话:{}、授课年级:{}、授课班级:{}'.
format(teacher_id, b[teacher_id][1], b[teacher_id][2],
b[teacher_id][3], b[teacher_id][4], m, ' '.join(n)))
print('*' * 106)
time.sleep(0.5)
break
elif choose == '2':
break
elif query == '6':
delete_teacher = input('请您输入需要删除老师的工号:')
if delete_teacher in b:
del b[delete_teacher]
print('教师信息已删除!')
else:
print('你输入的工号不存在,请核实!')
elif query == '7':
while True:
way = input('请您选择查询操作(1.查询个人 2.查询全部 3.退出查询):')
if way == '1':
student_id = input('请您输入需要查询同学的学号:')
if student_id in c:
print('*' * 5 + '学生信息' + '*' * 5)
print('学号:{}'.format(student_id))
print('姓名:{}'.format(c[student_id][4]))
print('性别:{}'.format(c[student_id][5]))
print('年龄:{}'.format(c[student_id][6]))
print('生日:{}'.format(c[student_id][7]))
print('电话:{}'.format(c[student_id][8]))
print('*' * 15)
else:
print('您输入的学生号码有误,请核实!')
elif way == '2':
print('*' * 30 + '学生信息' + '*' * 30)
for i in c:
print('学号:{}、姓名:{}、性别:{}、年龄:{}、生日:{}、电话:{}'.
format(i, c[i][4], c[i][5], c[i][6], c[i][7], c[i][8]))
print('*' * 67)
elif way == '3':
break
elif query == '8':
students_id = input('请您输入需要修改信息学生证号:')
if students_id in c:
while True:
students_change = input('请您选择修改选项(1.姓名 2.性别 3.年龄 4.生日 5.电话 6.退出):')
if students_change == '1':
name = input('请您输入姓名:')
c[students_id][4] = name
elif students_change == '2':
gender = input('请您输入性别:')
c[students_id][5] = gender
elif students_change == '3':
age = input('请您输入年龄:')
c[students_id][6] = age
elif students_change == '4':
birthday = input('请您输入生日(格式:2000-01-01):')
c[students_id][7] = birthday
elif students_change == '5':
phone = input('请您输入电话:')
c[students_id][8] = phone
elif students_change == '6':
break
else:
print('输入学生证号错误,请核对!')
print('*' * 30 + '学生信息' + '*' * 30)
print('学号:{}、姓名:{}、性别:{}、年龄:{}、生日:{}、电话:{}'.
format(students_id, c[students_id][4], c[students_id][5],
c[students_id][6], c[students_id][7], c[students_id][8]))
print('*' * 67)
time.sleep(0.5)
elif query == '9':
while True:
choose = input('是否继续操作(1.继续 2.退出)')
if choose=='1':
students_id = input('请您输入学生证号:')
if students_id in c:
print('学生证号已存在,请核实!')
else:
password = input('请您输入密码:')
professional = input('请您输入专业:').capitalize()
grade = input('请您输入年级:').capitalize()
Class = input('请您输入班级:').capitalize()
name = input('请您输入姓名:')
gender = input('请您输入性别:')
age = input('请您输入年龄:')
birthday = input('请您输入生日(格式:2000-01-01):')
phone = input('请您输入电话:')
c[students_id] = [password, professional, grade, Class,
name, gender, age, birthday, phone]
time.sleep(0.5)
print('学生信息录入成功')
print('*' * 53 + '学生信息' + '*' * 53)
print('学号:{}、专业:{}、年级:{}、班级:{}、姓名:{}、性别:{}、年龄:{}、生日:{}、电话:{}'.
format(students_id, c[students_id][1], c[students_id][2],
c[students_id][3], c[students_id][4], c[students_id][5],
c[students_id][6], c[students_id][7], c[students_id][8]))
print('*' * 113)
time.sleep(0.5)
if choose == '2':
break
elif query == '10':
while True:
choose = input('是否继续操作(1.继续 2.退出)')
if choose == '1':
students_id = input('请您输入需要删除学生证号:')
if students_id in c:
del c[students_id]
print('学生信息删除成功')
else:
print('学生证号不存在,请核实!')
if choose == '2':
break
elif query == '11':
while True:
way = input('请您选择查询方式(1.查询个人 2.查询全部 3.退出查询):')
if way == '1':
student_id = input('请您输入需要查询同学的学号:')
if student_id in c:
print('*' * 5 + '考试成绩' + '*' * 5)
print('学号:{}'.format(student_id))
print('姓名:{}'.format(c[student_id][4]))
print('语文:{}'.format(d[student_id]['语文']))
print('数学:{}'.format(d[student_id]['数学']))
print('英语:{}'.format(d[student_id]['英语']))
print('*' * 16)
time.sleep(0.5)
else:
print('输入学号不存在,请核实!')
if way == '2':
print('*' * 18 + '考试成绩' + '*' * 18)
for m in d:
if m in c:
print('学号:{}、姓名:{}、语文:{}、数学:{}、英语:{}'.
format(m, c[m][4], d[m]['语文'], d[m]['数学'], d[m]['英语']))
print('*' * 43)
if way == '3':
break
elif query == '12':
while True:
choose = input('是否继续操作(1.继续 2.退出)')
if choose == '1':
student_id = input('请您输入需要修改同学的学号:')
if student_id in c and student_id in d:
while True:
modified_grades = input('请您输入修改操作(1.语文 2.数学 3.英语 4.退出):')
if modified_grades == '1':
d[student_id]['语文'] = input('请您输入语文成绩:')
elif modified_grades == '2':
d[student_id]['数学'] = input('请您输入数学成绩:')
elif modified_grades == '3':
d[student_id]['英语'] = input('请您输入英语成绩:')
elif modified_grades == '4':
time.sleep(0.5)
print('成绩信息修改成功')
print('学号:{}、姓名:{}、语文:{}、数学:{}、英语:{}'.
format(student_id, c[student_id][4], d[student_id]['语文'],
d[student_id]['数学'], d[student_id]['英语']))
time.sleep(0.5)
break
else:
print('输入学号不存在,请核实!')
elif choose == '2':
break
elif query == '13':
while True:
entry = input('是否继续录入操作(1.继续 2.退出):')
if entry == '1':
student_id = input('请您输入需要录入同学的学号:')
if student_id in c:
d[student_id]['语文'] = input('请您输入语文成绩:')
d[student_id]['数学'] = input('请您输入数学成绩:')
d[student_id]['英语'] = input('请您输入英语成绩:')
time.sleep(0.5)
print('成绩信息录入成功')
print('*' * 5 + '考试成绩' + '*' * 5)
print('学号:{}'.format(student_id))
print('姓名:{}'.format(c[student_id][4]))
print('语文:{}'.format(d[student_id]['语文']))
print('数学:{}'.format(d[student_id]['数学']))
print('英语:{}'.format(d[student_id]['英语']))
print('*' * 16)
time.sleep(0.5)
else:
print('输入学号不存在,请核实!')
if entry == '2':
break
elif query == '14':
while True:
entry = input('是否继续录入操作(1.继续 2.退出):')
if entry == '1':
student_id = input('请您输入需要删除同学的学号:')
if student_id in c:
del d[student_id]
d[student_id] = {'语文': 0, '数学': 0, '英语': 0, }
time.sleep(0.5)
print('考试成绩删除成功')
print('*' * 5 + '考试成绩' + '*' * 5)
print('学号:{}'.format(student_id))
print('姓名:{}'.format(c[student_id][4]))
print('语文:{}'.format(d[student_id]['语文']))
print('数学:{}'.format(d[student_id]['数学']))
print('英语:{}'.format(d[student_id]['英语']))
print('*' * 16)
time.sleep(0.5)
else:
print('输入学号不存在,请核实!')
if entry == '2':
break
elif query == '15':
while True:
reserved = input('请您输入预留手机号码:')
if reserved == a[account][4]:
new_password = input('请您输入新密码:')
a[account][0] = new_password
time.sleep(0.5)
print('密码修改成功!新密码:{}'.format(new_password))
break
else:
print('号码错误,请您核实!')
modify = input('是否继续修改(1.继续 2.退出):')
if modify == '2':
break
elif query == '16':
break
elif account in a and a[account][0] != password:
print('密码错误,请您核实!')
else:
print('不好意思,账号错误!')
elif login_operation == '2':
retrieve_password = input('是否需要找回密码(1.需要 2.取消):')
if retrieve_password == '1':
while True:
administrator_id = input('请您输入管理账号:')
if administrator_id in a:
break
else:
print('工号错误,请您核实!')
while True:
phone = input('请您输入预留手机号码:')
if a[administrator_id][4] == phone:
break
else:
print('号码错误,请您核实!')
while True:
first_input = input('请您输入新密码:')
second_input = input('请再次输入密码:')
if first_input == second_input:
a[administrator_id][0] = first_input
time.sleep(0.5)
print('密码找回成功,请您重新登录!')
break
else:
print('两次密码不同,请您仔细核对!')
elif login_operation == '3':
break
复制代码
CSDN 博主「漫步桔田」原文链接:https://blog.csdn.net/u013157570/article/details/121886159
划线
评论
复制
发布于: 刚刚阅读数: 5
版权声明: 本文为 InfoQ 作者【漫步桔田】的原创文章。
原文链接:【http://xie.infoq.cn/article/4a76d94e7184089a2c054817a】。文章转载请联系作者。
漫步桔田
关注
编程届一名小学生,热心分享编程知识。 2022-08-25 加入
阿里云社区专家博主、CSDN领域新星创作者。
评论