用户账号系统(python)
生活随笔
收集整理的這篇文章主要介紹了
用户账号系统(python)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
user_list=[]#所有學生賬號儲存在該列表中
for i in range(1,201):temp={'name':'stu'+str(i),'password':'ppsuc'+str(i),'email':'stu'+str(i)+'@gd.com'}user_list.append(temp) #通過for循環創建200個現有學生賬號
print("歡迎使用公大教務系統!")while True:j=input("請選擇您的登陸方式:1.學生 2.管理員")if j == '1' :while True:l=input("請選擇要執行的操作:1.賬號密碼登錄 2.賬號注冊 3.密碼修改 4.退出系統")if l == '1' :m=input("請輸入用戶名:")n=input("請輸入密碼:")for a in range(0,len(user_list)): #for……else語句中,若for循環正常執行且循環完畢,則會繼續執行else中的語句。如果遇到break,則不執行else中的語句if m == user_list[a]['name']:if n== user_list[a]['password']:print("登陸成功,"+str(user_list[a]['name'])+"歡迎使用公大教務系統!")exit(0)else:print("用戶名或密碼輸入錯誤!請重新輸入")breakelse:print("輸入的用戶名不存在!請重新輸入")elif l == '2':while True:newname=input("請輸入一個用戶名:")for b in range(0, len(user_list)):if newname == user_list[b]['name']:print("該用戶名已被占用!請重新輸入")breakelse:newpassword=input("請輸入您的密碼:")test=input("請再次輸入密碼:")if newpassword != test:print("兩次輸入的密碼不一致!")breakelse:newmail=input("請輸入您的郵箱,用于找回密碼:")newtemp={'name':newname,'password':newpassword,'email':newmail}user_list.append(newtemp)print("注冊成功!請牢記您的用戶名、密碼及郵箱")print("用戶名:"+newname+" 密碼:"+newpassword+" 郵箱:"+newmail)breakelif l == '3':while True:exname=input("請輸入您要修改密碼的賬號(若輸入空賬號則返回上級):")if exname == "":breakfor c in range(0, len(user_list)):if exname == user_list[c]['name']:exmail=input("請輸入注冊賬號時綁定的郵箱:")if exmail == user_list[c]['email']:expassword=input("請輸入新的密碼:")testexpassword=input("請再次輸入密碼:")if expassword == testexpassword:user_list[c].update({'password':expassword})print("密碼修改成功!請重新登錄。")breakelse:print("兩次輸入的密碼不一致!")breakelse:print("郵箱錯誤!拒絕修改密碼。")else:print("您輸入的賬號不存在,請重新輸入")elif l == '4':exit(1)else:print("輸入的數據有誤!請重新輸入。")elif j == '2':k=input("請輸入管理員密碼:")if k=="AABBCCDDEEFF":print("登陸成功")while True:f = input("請選擇要執行的操作:1.輸出所有賬號信息 2.輸出單個賬號信息 3.修改賬號信息 4.退出系統")if f == '1':for e in range(0, len(user_list)):print("賬號:"+str(user_list[e]['name'])+" 密碼:"+str(user_list[e]['password'])+" 郵箱:"+str(user_list[e]['email']))elif f == '2':r=input("請輸入您想查看的賬號:")for a in range(0, len(user_list)):if r == user_list[a]['name']:print("賬號:"+str(user_list[a]['name'])+" 密碼:"+str(user_list[a]['password'])+" 郵箱:"+str(user_list[a]['email']))breakelse:print("您輸入的賬號不存在!")elif f == '3':r = input("請輸入您想修改的賬號:")for a in range(0, len(user_list)):if r == user_list[a]['name']:print("賬號:" + str(user_list[a]['name']) + " 密碼:" + str(user_list[a]['password']) + " 郵箱:" + str(user_list[a]['email']))s=input("請輸入要執行的操作:1.修改賬號密碼 2.修改賬號郵箱 3.刪除賬號 4.返回上一級")if s == '1':npassword=input("請輸入新的賬號密碼:")user_list[a].update({'password': npassword})print("修改密碼成功!")print("賬號:" + str(user_list[a]['name']) + " 密碼:" + str(user_list[a]['password']) + " 郵箱:" + str(user_list[a]['email']))breakelif s == '2':nmail = input("請輸入新的賬號郵箱:")user_list[a].update({'email': nmail})print("修改郵箱成功!")print("賬號:" + str(user_list[a]['name']) + " 密碼:" + str(user_list[a]['password']) + " 郵箱:" + str(user_list[a]['email']))breakelif s == '3':t=input("您確定要刪除該賬號嗎?刪除之后不可恢復。若確定刪除,請輸入管理員密碼:")if t == "AABBCCDDEEFF":user_list.pop(a)print("賬號刪除成功")breakelse:print("密碼輸入錯誤!拒絕刪除該賬號")breakelif s == '4':breakelse:print("輸入的值有誤!")breakelse:print("您輸入的賬號不存在!")elif f == '4':exit()else:print("輸入的數據有誤!請重新輸入。")else :print("管理員密碼輸入錯誤,拒絕訪問!")else :print("輸入的值有誤!請重新輸入。")
?
轉載于:https://www.cnblogs.com/P201821440033/p/11101627.html
總結
以上是生活随笔為你收集整理的用户账号系统(python)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 学习Kafka
- 下一篇: python实现归并排序