username = ‘cc‘ #用户名
userpassword = ‘123‘ #密码
count = 0 #计数器
while count<3: #如果计数小于3,即0,1,2共三次,则执行以下代码
_username = input("USER:")
_userpassword = input("PW:")
if _username == username and _userpassword == userpassword: #判断用户输入的用户名和密码是否一致
print("wlcome",username,"back.~~v-v".format(username=username))
break #一致则跳出循环
elif count<2:
print("not this user or password,try again")
count +=1
else:
print("lock!!!",username.format(username=username))代码很简单,希望一年后可以写出实用点的代码
原文:http://blog.51cto.com/wuliu92/2061871
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!