码迷,mamicode.com
首页 > 其他好文 > 详细

py18-作业

时间:2017-07-05 00:26:11      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:hang   pass   登录   退出   log   lock   ict   启动   readline   

1、可以支持多个用户登录 (提示,通过列表存多个账户信息)

用户3次认证失败后,退出程序,再次启动程序尝试登录时,还是锁定状态(提示:需把用户锁定的状态存到文件里)

#!/usr/bin/env python3
#-*- coding:utf-8 -*-
#Author: Zhang Lei

userdict = {"enven":111,"jack":222,"eray":333,"bike":444} count = 0 num = 0 while count < 3: username = input("What‘s your name? ") f = open("name.txt") date = f.readlines() date = ‘‘.join(date).strip(\n) f.close() if username in date: print ("sorry,your account is blocked.") break else: if username not in userdict: print("no,you guess error...") count += 1 continue elif username in userdict: print("year,input success...") while num < 3: passwd = input("plz input your passwd:") if passwd == str(userdict[username]): print("Yes, congratulations to you...") break elif num == 2: print("You are locked:", username) f = open(name.txt,a+) f.write(username +\n) f.close break else: print("plz input your passwd again:") num += 1 break

 

py18-作业

标签:hang   pass   登录   退出   log   lock   ict   启动   readline   

原文地址:http://www.cnblogs.com/zhangray/p/7119106.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!