zoukankan      html  css  js  c++  java
  • Python3 实现用户登陆,输入三次密码

    不加注释版

    #/usr/bin/python3
    import readline
    user = "seven"
    passwd = "123"
    username = input("please the enter user:")
    for i in range(3):
        password = input("please the enter password:")
        if password.isdigit():
            password = int(password)
            if username == user and password == passwd:
                print("logon successfull")
                break
            else:
                print("logon failed")
        else:
            print("logon failed")

    加注释版

    #/usr/bin/python3
    import readline#导入readline模块,否则无法移动光标和删除
    user = "seven"
    passwd = "123"#定义账号密码
    username = input("please the enter user:")#提示用户输入账号信息  
        for i in range(3):#如果登陆失败允许重复输入三次
        password = input("please the enter password")#提示用户输入密码
        if password.isdigit():#判断输入的是否是数字 是则进行下一步 否则返回失败
            password = int(password)#赋值定义密码等于输入密码
            if username == user and password == passwd:#判断账号和密码是否一致
                print("logon successfull")#True
                break
            else:
                print("logon failed")#False
        else:
            print("logon failed")#不是数字则返回False

    初接触Python 欢迎大家多多提意见

  • 相关阅读:
    [HNOI2002]营业额统计
    HDU 1374
    HDU 3345
    HDU 2089
    Graham扫描法
    Codeforces 1144D Deduction Queries 并查集
    Codeforces 916E Jamie and Tree 线段树
    Codeforces 1167F Scalar Queries 树状数组
    Codeforces 1167E Range Deleting
    Codeforces 749E Inversions After Shuffle 树状数组 + 数学期望
  • 原文地址:https://www.cnblogs.com/Gnnnny/p/7998035.html
Copyright © 2011-2022 走看看