li = [{‘username‘:‘alex‘,‘password‘:‘123‘}, {‘username‘:‘wusir‘,‘password‘:‘23‘}, {‘username‘:‘taibai‘,‘password‘:‘34‘}, ]j = 0while j < 3 : username = input(‘姓名:‘) password = input(‘密码:‘) for i in li : if username == i[‘username‘] and password == i[‘password‘]: print(‘登陆成功!‘) j=3 break else: print(‘登陆不成功,请重新输入~‘) if j == 2: choice = input(‘是否再试试?Y‘) if choice==‘Y‘: j=-1 j=j+1
原文地址:https://www.cnblogs.com/deja/p/8780262.html
时间: 2024-10-29 11:38:04