首页 > 代码库 > 51_work--模拟登陆
51_work--模拟登陆
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()
51_work--模拟登陆
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。