1. 程式人生 > >聯系-登陸認證

聯系-登陸認證

登陸認證

import io #創建賬戶,賬戶“類型,帳戶名,密碼” def creat_account(): with open("17-login.txt","a") as f: type=input("Input the type:") # f.write(type+"\n") acc=input("Input the account:") # f.write(acc+"\n") pwd=input("Input the pwd:") # f.write(pwd+"\n") f.write(type+"\n"+acc+"\n"+pwd+"\n") Home_list(login,state) state=False #登陸狀態,默認False db_users=[] #臨時提取user的類型,賬號,密碼。作為list存儲 #登陸首頁 def home_page(func,state): if not state: #判斷登陸狀態 func(Home_list,state) else: print("登陸首頁成功!") Home_list(func,state) #登陸金融頁 def finance_page(func,state): if not state: #判斷登陸狀態 func(Home_list,state) else: print("登陸金融頁成功!") Home_list(func,state) #登陸購物車 def shop_car(func,state): if not state: #判斷登陸狀態 func(Home_list,state) else: print("登陸購物車成功!") Home_list(func,state) #登陸驗證 def login(func,state): #從文件中提取用戶數據 with open("17-login.txt","r") as f: for line in f.readlines(): db_users.append(line.strip()) jd=db_users[0:3] #京東登陸的用戶 wx=db_users[3:6] #微信登陸的用戶 if not state: #判斷登陸狀態 while True: #輸入有誤或者不匹配要求重新輸入 input_type=input("Input your login_type:")#輸入登陸類型 input_account=input("Input your account:")#輸入密碼 input_pwd=input("Input your pwd:")#輸入密碼 if input_type==jd[0]: if input_account==jd[1] and input_pwd==jd[2]: state=True print("Welcome %s!!!"%jd[1]) func(login,state) break else: print("Err,account or passward was wrong!") elif input_type==wx[0]: if input_account==wx[1] and input_pwd==wx[2]: state=True print("Welcome %s!!!"%wx[1]) func(login,state) break else: print("Err,account or passward was wrong!") else: print("ERR,Input was wrong!again,please...") else: func(login,state) #首頁選項 choose="" def Home_list(func,state): print("""List: 1.creat new accout 2.open Home Page 3.open Finance Page 4.open Shopping Car 5.exit""") choose=input("Input your choose:") if choose=="1": creat_account() elif choose=="2": home_page(func,state) elif choose=="3": finance_page(func,state) elif choose=="4": shop_car(func,state) elif choose=="5":#退出登陸狀態 print("account was out!") Home_list(login,state=False) else: print("ERR,input was wrong!") Home_list(login,state) Home_list(login,state)


聯系-登陸認證