students_system = {
'class_name':'xinji1501','民族':'汉族',
'students':[
{'name': 'stu1', 'age': 18, 'tel': 110},
{'name': 'stu2', 'age': 18, 'tel': 111},
{'name': 'stu3', 'age': 18, 'tel': 112}
]
}
name = input('请输入姓名')
age = input('请输入年龄')
tel = input('请输入电话')
add_student = {'name': name, 'age': age, 'tel': tel}
students_system['students'].append(add_student)
print(students_system)
del_student = input('请输入删除学生的姓名:')
all_students = students_system['students']
for student_dict in all_students[:]:
if student_dict == del_student:
all_students.remove(student_dict)
print(students_system)
gai_student = input('请输入修改学生的姓名')
gai_tel = input('请输入修改的电话:')
all_tel = students_system['students']['tel']
for tel_dic in range(len(students_system['students'])):
if tel_dic == students_system['students']['tel']:
students_system['students']['tel']=gai_tel
print(students_system)
网友评论