user = ‘hsjhj‘ passwd = ‘admin‘ count = 3 while count > 0: name = input(‘请输入用户名:‘) pwd = input("请输入密码:") if name == user and pwd == passwd: print(‘欢迎登陆‘) break count -= 1 print(‘你的输入有误,你还剩余%s次‘ % count)
原文:https://www.cnblogs.com/weiliwei-lucky/p/11156345.html