Python learning begins at the end of November 2017. Select Python 3.6.
Rough implementation of account login.
1 ImportGetpass2 3Wall =True4usr ='Root'5PASWD = 00006block_list = open ("Test.txt",'a')7 Print("Sign in!")8 9 forIinchRange (3, 0, 1):Ten Print('{Time} time (s) left'. Format (time=i)) Oneusr_in = input ("Username:") Apaswd_in = Int (input ("Password:"))# - #Password = getpass.getpass ("Password:") - the forLineinchOpen'Test.txt'): - ifline = =usr: - Print('Your account is blocked!') -Wall =False + Break - + ifWall isFalse: A Print('Call you admin!') at Break - elifusr = = usr_in andPaswd_in = =paswd: - Print('------Welcome {_name}!------'. Format (_name=usr)) - Break - Else: - ifI! = 1: in Print('Invalid Password or username!\nplease try again!') - Else: to Print('Your account is Blocked!\ncall Your admin!') +Block_list.writelines ('{0}'. Format (usr)) - theBlock_list.close ()
Python study first week-account login Exercise