标签:use else name imp you input invalid admin port
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()
标签:use else name imp you input invalid admin port
原文地址:http://www.cnblogs.com/shuiyy/p/7988886.html