students_info={ '3130660001':{ 'name':'阿忆', 'passwd':'000000', 'gender':1,#1:男,2:女 'class':1, 'born':1994/5 } } admin_info={ 'root':'passwd' } #管理员模块 def admin(): admin_menu=""" 1.管理员登录, 2.管理员密码修改, 3.添加学生的信息, 4.删除学生的信息, 5.修改学生的信息, 6.查询学生的信息(根据学号), 7.查看所有学生的信息, 8.退出系统(exit(0)), """ print("欢迎进入管理员登陆系统界面!".center(40,'*')) print(admin_menu) choice=int(input('请输入您的选择:')) if choice==1: trycount = 0 while trycount < 3: trycount += 1 inuser = input("用户名:").strip() if inuser in admin_info: # 判断用户是否存在? inpasswd = input('密码:') passwd = admin_info[inuser]['passwd'] # 找出系统存储的inuser用户的密码 if inpasswd == passwd: # 判断密码是否正确? print('%s登录成功!' % (inuser)) break else: print('用户%s的密码错误!' % (inuser)) else: print('用户名%s不存在' % (inuser)) else: print('尝试次数超过3次!') elif choice==2: print('您选择修改密码该功能!') while True: newpasswd=input('请输入新的密码:') if not newpasswd: print('密码不能为空,请重新输入') else: break againpasswd=input('请再次输入密码:').strip() if againpasswd==newpasswd: admin_info['inuser']=newpasswd elif choice ==3: print('您选择添加学生信息该功能!') inname=input("请输入要添加学生的姓名:").strip() student_ID=input('请输入学生学号(学号不可重复):') gender = input(" 性别(1-男,2-女):") age = int(input("*年龄:")) if student_ID in students: # 判断学号是否已经存在? print('用户%s已存在!' % (inname)) else: student_info = {} #定义字典,用来存放单个学生的信息 student_info['id'] = student_ID student_info['name'] = inname student_info['gender'] = gender student_info['age'] = age students.append(student_info) print('学生%s添加成功' % (inname)) elif choice ==4: print('您选择的是删除学生功能') delId=input('请输入要删除的学生学号:') if delId not in students_info: print('请输入正确的学号') else: print('学号%s的学生信息:%s'%(delId,students_info)) del students_info[delId] print('该学生信息已经删除') elif choice ==5: while True: modId=input('请输入要修改学生的学号:').strip() if modId not in students_info: print('该学生信息不存在') else: print('学号%s学生的信息为:%s'% (modId,students_info)) print(' 请输入修改后的信息:') while True: modname=input('*姓名:').strip() if not modname: print('姓名不能为空') else: break while True: modgender=input('性别(1-男,2-女):').strip() if not modgender: modgender=None else: modgender=modgender break modclass=input('班级:').strip() if not modclass: modclass=None else: modclass=modclass modborn=input('出生年月(year/month):').strip() if not modborn: modborn=None else: modborn=modborn modpasswd=input('*密码:') if not modpasswd: print('密码不能为空,请重新输入!') else: modpasswd=modpasswd break students_info[modId]={ 'name':modname, 'gender':modgender, 'class':modclass, 'born':modborn, 'passwd':modpasswd } print('信息修改成功!') break elif choice ==6: while True: lookId=input('请输入查询学生学号:').strip() if lookId not in students_info: print('无该学生信息') else: print(students_info[lookId]) elif choice ==7: print(students_info) elif choice ==8: exit(0) else: print('Error!您的选择有误,请输入正确的选择!谢谢!') #学生操作模块: def students(): student_menu = """ 1.学生登陆, 2.查询个人信息, 3.修改个人信息, 4.注销用户 """ print('01-学生登录系统界面'.center(40,'*')) while True: print(student_menu) choice2=int(input('请输入您的选择:')) if choice2==1: for j in range(3): student_name=input('请输入用户名(学号):').strip() if student_name not in students_info: print('该用户不存在!请重新输入:') else: student_passwd=input('请输入密码:').strip() if student_passwd==students_info[student_name]: print('登录成功!') else: print('密码错误') else: print('尝试次数超过3次,退出系统') elif choice2==2: print(students_info[student_name]) elif choice2==3: cla=input('class:').strip() if not cla: cla = None else: cla =cla born=input('出生年月(year/month):') if not born: born=None else: born=born while True: passwd = input('密码:').strip() if not passwd: print('密码不能为空') else: break m = input('<1:确认修改 2;取消>').strip() if m =='1': students_info[student_name]['class']=cla students_info[student_name]['born']=born students_info[student_name]['passwd']=passwd print('信息修改成功!') break elif m =='2': break else: print('无效输入') elif choice2 ==4: exit(0) else: print('请输入正确的选择') def main(): menu=''' 1.管理员登录 2.学生登录 ''' print('学生信息管理系统'.center(40,'*')) print(menu) while True: choice1 = int(input('请输入您的选择:')) if choice1==1: admin() elif choice1==2: students() else: print('请输入正确的选择!') main()
学生信息管理系统
猜你喜欢
转载自blog.csdn.net/xijiao_jiao/article/details/80196643
今日推荐
周排行