码迷,mamicode.com
首页 > 其他好文 > 详细

联系-登陆认证

时间:2018-04-17 19:40:15      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:登陆认证

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)


联系-登陆认证

标签:登陆认证

原文地址:http://blog.51cto.com/zhangkaiei/2104549

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!