2017年11月底開始python的學習。選擇python 3.6。 賬號登陸的粗糙實現。 ...
2017年11月底開始python的學習。選擇python 3.6。
賬號登陸的粗糙實現。
1 import getpass 2 3 wall = True 4 usr = 'root' 5 paswd = 0000 6 block_list = open("test.txt", 'a') 7 print("Please sign in!") 8 9 for i in range(3, 0, -1): 10 print('{time} time(s) left'.format(time=i)) 11 usr_in = input("username: ") 12 paswd_in = int(input("password:")) # 13 # password = getpass.getpass("password:") 14 15 for line in open('test.txt'): 16 if line == usr: 17 print('Your account is blocked!') 18 wall = False 19 break 20 21 if wall is False: 22 print('Call you admin!') 23 break 24 elif usr == usr_in and paswd_in == paswd: 25 print('------ Welcome {_name}! ------'.format(_name=usr)) 26 break 27 else: 28 if i != 1: 29 print('Invalid password or username!\nPlease try again!') 30 else: 31 print('Your account is blocked!\nCall your admin!') 32 block_list.writelines('{0}'.format(usr)) 33 34 block_list.close()