Day01 login module,day01loginmodule

來源:互聯網
上載者:User

Day01 login module,day01loginmodule

知識點:模組匯入  變數賦值的兩種形式  格式化輸出  for迴圈  if...else 嵌套

#!C:\Program Files\Python35/bin# -*- conding:utf-8 -*-# author: Frankimport getpassuser,passwd= 'Frank','oldboy_python'msg = '''Information of %s person:NAME: %sAGE:  %sJOB:  %sID :  %s''' %(user,user, 21, 'IT Engineer',3714)input_time = 1for 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:frankplease input your password:dmfkdfYour user or password is invalid , pleasre re_input!-----input 2 time-----please input your name:frankplease input your password:kdfYour user or password is invalid , pleasre re_input!-----input 3 time-----please input your name:Frkdfkplease input your password:mskYour input has 3 times wrong , your account will be locked#測試2-----input 1 time-----please input your name:Frankplease input your password:oldboy_pythonFrank Welcom to login onIf you need double check your personal inform yes/no:yesInformation of Frank person:NAME: FrankAGE:  21JOB:  IT EngineerID :  3714# 測試3:-----input 1 time-----please input your name:frakplease input your password:mksf34Your user or password is invalid , pleasre re_input!-----input 2 time-----please input your name:mddifplease input your password:frank3235Your user or password is invalid , pleasre re_input!-----input 3 time-----please input your name:Frankplease input your password:oldboy_pythonFrank Welcom to login onIf you need double check your personal inform yes/no:noplease go ahead

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.