py18-作业
Posted 北冥有鱼
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了py18-作业相关的知识,希望对你有一定的参考价值。
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-作业的主要内容,如果未能解决你的问题,请参考以下文章
HTML5期末大作业:餐饮美食网站设计——咖啡(10页) HTML+CSS+JavaScript 学生DW网页设计作业成品 web课程设计网页规划与设计 咖啡网页设计 美食餐饮网页设计...(代码片段