zoukankan      html  css  js  c++  java
  • Day01 login module

    知识点:模块导入  变量赋值的两种形式  格式化输出  for循环  if...else 嵌套

    #!C:Program FilesPython35/bin
    # -*- conding:utf-8 -*-
    # author: Frank
    import getpass
    user,passwd= 'Frank','oldboy_python'
    msg = '''
    Information of %s person:
    NAME: %s
    AGE:  %s
    JOB:  %s
    ID :  %s
    ''' %(user,user, 21, 'IT Engineer',3714)
    input_time = 1
    for i in range(5):
            print("-----input %d time-----" %int((input_time)))
            username = input("please input your name:")
         #   password = getpass.getpass("please input your password:")
            password = input("please input your password:")
            if username == user and password == passwd :
                print("%s Welcom to login on" %(user))
                info_confirm = input("If you need double check your personal inform yes/no:")
                if info_confirm == 'yes':
                    print(msg)
                    break
                else:
                    print("please go ahead")
                    break
            else :
                if input_time == 3:
                    print("Your input has 3 times wrong , your account will be locked")
                    exit()
                else:
                   print("Your user or password is invalid , pleasre re_input!")
                   input_time += 1

    测试结果:

    #测试1
    -----input 1 time-----
    please input your name:frank
    please input your password:dmfkdf
    Your user or password is invalid , pleasre re_input!
    -----input 2 time-----
    please input your name:frank
    please input your password:kdf
    Your user or password is invalid , pleasre re_input!
    -----input 3 time-----
    please input your name:Frkdfk
    please input your password:msk
    Your input has 3 times wrong , your account will be locked
    
    #测试2
    -----input 1 time-----
    please input your name:Frank
    please input your password:oldboy_python
    Frank Welcom to login on
    If you need double check your personal inform yes/no:yes
    
    Information of Frank person:
    NAME: Frank
    AGE:  21
    JOB:  IT Engineer
    ID :  3714
    
    # 测试3:
    -----input 1 time-----
    please input your name:frak
    please input your password:mksf34
    Your user or password is invalid , pleasre re_input!
    -----input 2 time-----
    please input your name:mddif
    please input your password:frank3235
    Your user or password is invalid , pleasre re_input!
    -----input 3 time-----
    please input your name:Frank
    please input your password:oldboy_python
    Frank Welcom to login on
    If you need double check your personal inform yes/no:no
    please go ahead
  • 相关阅读:
    HTML
    初学网页
    刚学了函数,关于有无参数和返回值的四种情况的查找数字的代码
    输入五个学生的成绩,得到成绩表
    验证你的邮箱是不是qq邮箱
    摘自评论。
    LINQ Except “引用类型” 用法
    梦到钢笔
    MVC传参数给js的时候 如果是数值 变量要进行一下转换才能正确识别 例如var aaa = parseInt('@Model.ClickIndex');
    绝对路径相对路径
  • 原文地址:https://www.cnblogs.com/frankb/p/6095641.html
Copyright © 2011-2022 走看看