# _*_coding:utf-8_*_# Author:len liu ‘‘‘让用户输入用户名密码认证成功后显示欢迎信息输错三次后退出程序‘‘‘ user_list = { "len":‘aaa‘, "alen":‘bbb‘, "blen":‘ccc‘}count = 0while True: user_input = input("pls input username:") passwd_input = input("pls input password:") if user_input not in user_list: print("no this user") continue with open(‘black_list.txt‘,‘r‘) as f: lock_user=f.read().split(‘,‘) #print(lock_user) if user_input in lock_user: print(‘your count %s locked!‘%user_input) break if user_input in user_list and passwd_input == user_list[user_input]: print("login sucessful!") break else: print("invaild username or password") count +=1 if count >2 : with open(‘black_list.txt‘,‘a‘) as f: f.write(user_input +‘,‘) print("your count try too times ,locked!") break
原文地址:https://www.cnblogs.com/len1028/p/9228299.html
时间: 2024-10-09 13:54:43