国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python用戶管理系統

2020-01-04 15:39:59
字體:
來源:轉載
供稿:網友

本文實例為大家分享了Python用戶管理系統的具體代碼,供大家參考,具體內容如下

用戶管理系統

1.注冊新用戶
如果注冊用戶已經存在,則報錯
需要填寫信息: name, passwd, gender, email,age
2.用戶登錄 要求同之前寫的用戶登錄系統
3.注銷用戶 用戶注銷時,需要輸入用戶名和正確的用戶密碼
4.顯示用戶信息 顯示系統中存在所有已經注冊用戶的信息
5.退出系統

代碼如下

#!/usr/bin/env python#coding:utf-8info = """************************************************************   用戶登錄管理系統************************************************************   1. 注冊新用戶   2. 用戶登錄   3. 用戶注銷   4. 用戶信息顯示   5. 退出系統"""userinfo = { 'root': { 'name': 'root', 'password': 'redhat', 'gender': 1, 'email': '', 'age': 12 },}gender_choice = [0, 1, 2]def CreateUser(): print "注冊用戶界面".center(50, '*') name = raw_input("*注冊用戶名:") if name in userinfo: print "用戶已存在,請更換注冊名" else: password = raw_input("*用戶密碼:") while True:  gender = input("*性別(0-男 1-女 2-其他):")  if gender in gender_choice:  break  else:  print "請輸入正確的選擇" email = raw_input("用戶郵箱:") if not email:  email = None age = raw_input("年齡:") if not age:  age = None else:  age = int(age) userinfo[name] = {  'name': name,  'password': password,  'gender': gender,  'email': email,  'age': age, } print "%s 用戶注冊成功!!!" % (name)def UserLogin(): print "用戶登錄界面".center(50, '*') trycount = 0 while trycount < 3: name = raw_input("登錄用戶名:") if name not in userinfo:  print "用戶未注冊"  break password = raw_input("登錄密碼:") trycount += 1 if password == userinfo[name]['password']:  print "恭喜%s登錄成功" % (name)  break else:  print "請輸入正確的用戶名或密碼!" else: print "已登錄三次,請稍后再試"def DeleteUser(): print "用戶注銷界面".center(50, '*') name = raw_input("注銷用戶名:") if name not in userinfo: print "用戶未注冊" else: password = raw_input("登錄密碼:") if password == userinfo[name]['password']:  userinfo.pop(name)  print "恭喜注銷%s成功" % (name)def UserInfo(): for key, value in userinfo.items(): print "用戶:%s" % (key), print "性別:%d" % (value['gender']), print "郵箱:%s" % (value['email']), print "年齡:%s" % (value['age']), print "/n/n"def main(): while True: print info choice = raw_input("Choice:").strip() if choice == "1":  CreateUser() elif choice == "2":  UserLogin() elif choice == "3":  DeleteUser() elif choice == "4":  UserInfo() elif choice == "5":  exit() else:  print "輸入正確的選擇"main()

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到python教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 姜堰市| 武山县| 泌阳县| 泰来县| 滁州市| 闽侯县| 嘉善县| 渝北区| 隆回县| 易门县| 泰安市| 陆川县| 乡城县| 牙克石市| 临猗县| 房山区| 台东县| 永仁县| 吴川市| 台湾省| 福贡县| 错那县| 漳浦县| 磐安县| 昭平县| 漳平市| 阿拉善右旗| 东阳市| 基隆市| 满城县| 普兰县| 连州市| 习水县| 游戏| 福安市| 大安市| 赤峰市| 湖南省| 视频| 泸水县| 巫溪县|