美文网首页
day07homework

day07homework

作者: DoubleKou | 来源:发表于2018-08-29 08:33 被阅读0次
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)

相关文章

网友评论

      本文标题:day07homework

      本文链接:https://www.haomeiwen.com/subject/fjxhwftx.html