标签:pwd lin inpu time pass exit readlines file man
import sys count=0 while count<3: user = input("Please enter user name:") lock_file = open(‘D:\\lock.txt‘, ‘r+‘) lock_list = lock_file.readlines() for lock_line in lock_list: lock_line = lock_line.strip(‘\n‘) if user == lock_line: print(‘The user has been locked‘) sys.exit() user_file = open("D:\\username.txt", ‘r‘) user_list = user_file.readlines() for user_line in user_list: name, pwd = user_line.strip(‘\n‘).split() if user == name: count_1 = 0 while count_1 < 3: password = input(‘Please enter user password:‘) if password == pwd: print(‘%s welcome!‘ % user) sys.exit() else: print(‘Password error‘) count_1 += 1 if count_1 == 3: print(‘The password has been entered many times. The user has been locked‘) lock_file.write(user) sys.exit() else: pass else: if count != 2: print(‘The username does not exist‘) count += 1 else: print(‘The username has been entered many times‘) sys.exit()
标签:pwd lin inpu time pass exit readlines file man
原文地址:http://www.cnblogs.com/zy-study/p/7115229.html