学生信息管理系统
data = [
{
'ID': '2019304169',
'Name': '陈雪晨',
'Sex': '男',
'Address': '安徽宿州'
},
{
'ID': '2019304142',
'Name': '刁雨露',
'Sex': '女',
'Address': '安徽阜阳'
}
]
def show_all():
for student in data:
print(student)
def creat_student():
ID = input('请输入学生ID:')
Name = input('请输入学生姓名:')
Sex = input('请输入学生性别:')
Address = input('请输入学生地址:')
student = {
'ID': ID,
'Name': Name,
'Sex': Sex,
'Address': Address
}
data.append(student)
def find_student():
Name = input('请输入要查询的学生姓名:')
for student in data:
if student['Name'] == Name:
print(student)
return
else:
print('查无此人')
def change_student():
Name = input('请输入要修改信息的学生姓名:')
for student in data:
if student['Name'] == Name:
print(student)
student['ID'] = input('请输入学生ID:')
student['Name'] = input('请输入学生姓名:')
student['Sex'] = input('请输入学生性别:')
student['Address'] = input('请输入学生地址:')
return
else:
print('查无此人')
def remove_student():
ID = input('请输入要删除信息的学生ID:')
for student in data:
if student['ID'] == ID:
print(student)
data.remove(student)
print('删除成功')
return
else:
print('查无此人')
while True:
print('''
**************************
1.显示所有学生信息
2.新建学生信息
3.查询学生信息
4.修改学生信息
5.删除学生信息
0.退出系统
**************************
''')
op = input('请输入操作步骤:')
if op == '1':
show_all()
elif op == '2':
creat_student()
print('添加成功')
elif op == '3':
find_student()
elif op == '4':
change_student()
elif op == '5':
remove_student()
elif op == '0':
print('退出系统')
break
|