• ~~~~练习~~~~用户登录(三次机会重试)


    基础需求:

    • 让用户输入用户名密码
    • 认证成功后显示欢迎信息
    • 输错三次后退出程序

    count=1 PS=0 name=input("Please input your name:") password=input("Please input your password:") while count<=2 and PS==0: if name=="root" and password=="1234": PS=1 print("Welcome!") elif count==2: name=input("Lasttime!Please enter :") password=input("Please input your password:") count+=1 else: name=input("Wrong! Please enter again:") password=input("Please input your password:") count+=1 if count==3 and PS==0: print("End!!")

      

    可以支持多个用户登录

    count=1    #登录次数计数位
    PS=0   #登录成功标志位
    name_list=['root','hao','quan']
    ps_list=['123456','111','666']
    name=input("Please input your name:")
    password=input("Please input your password:")
    
    while count<=3 and PS==0:
        if name in name_list:
            i=name_list.index(name)
            if (name in name_list) and (password==ps_list[i]):
                PS=1
                print("Welcome!")
            elif count<2 :
                name=input("Wrong! Please enter again:")
                password=input("Please input your password:")
                count+=1
                continue
            else :
                name=input("Lasttime!Please enter :")
                password=input("Please input your password:")
                count+=1
                continue
        elif count==2 and PS==0:
            name=input("Lasttime!Please enter :")
            password=input("Please input your password:")
            count+=1
        else:
            name=input("Wrong! Please enter again:")
            password=input("Please input your password:")
            count+=1
    
    if count==3 and PS==0:
        print("End!!")
  • 相关阅读:
    Ios开发中UILocalNotification实现本地通知实现提醒功能
    Oracle 客户端连接时报ORA-01019错误总结
    linux中合并多个文件内容到一个文件的例子
    java截取字符串函数
    springcloud 笔记
    Aop笔记
    SpringMvc返回Json调试
    jackjson-databind-2.9.3 笔记
    MyBatis 笔记
    Jvm 10 升级笔记
  • 原文地址:https://www.cnblogs.com/haoy/p/10164857.html
Copyright © 2020-2023  润新知