文章标题
2017-08-29 20:32
288 查看
题目1:用户管理系统V2:
用户功能如下:
welcome to xxxx system
1.注册:若用户存在,直接报错”name 已经存在”,若用户不存在,将用户信息保存起来,显示”注册成功”;
2.登陆:若用户存在,判断密码是否正确,若用户不存在,报错”name 不存在”;
3.注销:若用户存在,删除用户信息;若不存在,报错报错”name 不存在;
4.退出:break
#!/usr/bin/env python #coding=utf-8 d={"root":"westos"} def ZhuCe(): for i in d.keys(): ZhuCe_User = raw_input("please input Zhuce username:") ZhuCe_PassWd=raw_input("please input zhuce password:") if ZhuCe_User==i: print "用户已经存在!" if ZhuCe_User!=i: d.setdefault(ZhuCe_User,ZhuCe_PassWd) print "创建成功" break def DengLu(): for i in range(1, 4): check_UserName = raw_input("please input your username:") check_PassWord = raw_input("please input your passwd :") if check_UserName in d.keys() and check_PassWord in d.values(): print ("login ok") break elif check_UserName not in d.keys(): print ("user is not exist") elif check_PassWord not in d.values(): print ("password is no ok") print "count is bigger than 3" def ZhuXiao(): ShanChu_user=raw_input("please input ShanChu username:") if ShanChu_user not in d.keys(): print "user is not exist" else: d.pop(ShanChu_user) print "删除成功" while 1: pro=''' welcome to Linux system 1.注册(Z) 2.登陆(D) 3.注销(A) 4.退出(Q) please input your choice:''' choice=raw_input(pro).upper() if choice in "Zz": ZhuCe() elif choice in "Dd": DengLu() elif choice in "Aa": ZhuXiao() elif choice in "Qq": break else: print "input your choice:"