1.编写登录接口:

- 输入用户名和密码

- 认证成功后显示欢迎信息

- 输错三次后锁定

 #!/usr/bin/env python
# -*- coding:utf-8 -*- import sys,os dir = os.getcwd() Count = 0 STATUS = True
while STATUS:
L_user = input("you username:").strip()
with open(dir+"\lock.txt","r+") as f:
for n in f.readlines():
if L_user == n.strip("\n"):
print("username is lock!!!")
sys.exit()
L_passwd = input("you passwd:")
with open(dir+"\passwds.txt","r+") as f1:
for line in f1.readlines():
user,passd = line.strip("\n").split(":")
if L_user == user and L_passwd ==passd:
print("Welcome to login successfully")
sys.exit()
else:
print("login faile")
Count += 1
if Count == 3:
print("sorry ,then three time ,username lock!!!")
with open(dir+"\lock.txt","a+") as f2:
f2.write(L_user+"\n")
STATUS = False

2.编写多级菜单

- 三级菜单

- 可依次进入子菜单

第一次写python脚本,因为没有学到函数,所以写的有点糙和繁琐,我用自己学到的知识来实现这些需求。大家也可试一试。

#!/usr/bin/env python
# -*- coding:utf-8 -*- import sys meau = {
"北京":{
"通州":["梨园","果园","土桥"],
"朝阳":["将台","望京","关庄"],
"海淀":["色色","吸收","里是"]
},
"天津":{
"滨海":["但是","分手","而是"],
"光华":["厚爱","感觉","色鬼"],
"经济":["回来","反对","沟通"]
},
"河北":{
"邯郸":["是啊","在啊","怕看"],
"邢台":["个是","的个","是和"],
"保定":["先动","个他","不发"]
},
} Shi = []
Status = True
try:
while Status:
for k in meau:
print(k)
choose = input("b:back,q:quie,choose:")
if choose in meau:
Shi.append(meau)
meau = meau[choose]
elif choose == "b":
if Shi:
meau = Shi.pop()
elif choose == "q":
Status = False
     else:
      print("input error")
except TypeError as e:
print(choose)

  

 #!/usr/bin/env python
#NameFile:test.py
#Import time module
import time
import sys
#Define a number of variables
sum = 0
H = {'':'白石桥','':'东直门','':'复兴路'}
K = {'':'灵石路','':'宝山路','':'康乐路'}
P = {'':'和平路','':'辽宁路','':'新华路'}
J = {'':'大井湾','':'王家湾','':'茅溪村'}
B = {'':'海淀区','':'朝阳区','':'东城区','':'西城区'}
S = {'':'黄浦区','':'虹口区','':'长宁区','':'徐汇区'}
T = {'':'和平区','':'河东区','':'河北区','':'河西区'}
C = {'':'江北区','':'长寿区','':'荣昌区','':'巴南区'}
City = {
'':'北京市',
'':'上海市',
'':'天津市',
'':'重庆市',
}
#Registered account
user = input("User:").strip()
if len(user) == 0 :
print ("User cannot be empty!!!")
elif len(user) > 6:
print ("Your username is too long!!")
passwd = input("Passwd:")
if len(passwd) == 0 :
print ("Passwd cannot be empty!!!")
elif len(passwd) > 6:
print ("You set the password is too long!!")
#Format the user's account and password
list = """
Your account password is as follows:
user:%s
passwd:%s"""%(user,passwd)
print (list)
print ("Congratulations on your registration,Please login again after five seconds.")
#Wait five seconds to allow the user to re-enter
time.sleep(5)
#Please login again
while sum < 3:
User = input("please you input user:").strip()
if len(User) == 0 :
print ("User cannot be empty!!!")
elif len(User) > 6:
print ("Your username is too long!!")
Passwd = input("please you input passwd:")
if len(Passwd) == 0 :
print ("paswd cannot be empty!!!")
elif len(Passwd) > 6:
print ("You set the password is too long!!")
if User == user and Passwd == passwd:
print ("Welcome you to log in.After five seconds to enter the selection interface")
break
else:
print ("Your account or password is incorrect. Please log in again.!!!")
#Number of users log on to count more than three times to lock the account
sum += 1
if sum > 4:
print ("You log in too many, will lock your user!!!!")
time.sleep(5)
for k,v in City.items():
print (k,v)
while True:
print ('Q:退出')
A = input('Please select:').strip()
if A == '':
for k,v in B.items():
print (k,v)
print ('Q:退出')
G = input ('Please continue to choose:').strip()
if G == '':
for k,v in H.items():
print (k,v)
print ('Q:退出')
Y = input ('please continue:').strip()
if Y == '':
print ('You choose is:',H[''])
sys.exit()
elif Y == '':
print ('You choose is:', H[''])
sys.exit()
elif Y == '':
print ('You choose is:',H[''])
sys.exit()
elif Y == 'Q':
print ('Welcome to come again next time.')
sys.exit()
if G == 'Q':
print ('Welcome to come again next time.')
sys.exit()
if A == '':
for k,v in S.items():
print (k,v)
print ('Q:退出')
G = input ('Please continue to choose:').strip()
if G == '':
for k,v in K.items():
print (k,v)
print ('Q:退出')
Y = input ('please continue:').strip()
if Y == '':
print ('You choose is:',K[''])
sys.exit()
elif Y == '':
print ('You choose is:', K[''])
sys.exit()
elif Y == '':
print ('You choose is:',K[''])
sys.exit()
elif Y == 'Q':
print ('Welcome to come again next time.')
sys.exit()
if G == 'Q':
print ('Welcome to come again next time.')
sys.exit()
if A == '':
for k,v in T.items():
print (k,v)
print ('Q:退出')
G = input ('Please continue to choose:').strip()
if G == '':
for k,v in P.items():
print (k,v)
print ('Q:退出')
Y = input ('please continue:').strip()
if Y == '':
print ('You choose is:',P[''])
sys.exit()
elif Y == '':
print ('You choose is:', P[''])
sys.exit()
elif Y == '':
print ('You choose is:',P[''])
sys.exit()
elif Y == 'Q':
print ('Welcome to come again next time.')
sys.exit()
if G == 'Q':
print ('Welcome to come again next time.')
sys.exit()
if A == '':
for k,v in C.items():
print (k,v)
print ('Q:退出')
G = input ('Please continue to choose:').strip()
if G == '':
for k,v in J.items():
print (k,v)
print ('Q:退出')
Y = input ('please continue:').strip()
if Y == '':
print ('You choose is:',J[''])
sys.exit()
elif Y == '':
print ('You choose is:', J[''])
sys.exit()
elif Y == '':
print ('You choose is:',J[''])
sys.exit()
elif Y == 'Q':
print ('Welcome to come again next time.')
sys.exit()
if G == 'Q':
print ('Welcome to come again next time.')
sys.exit()
if A == 'Q':
print ('Welcome to come again next time.')
sys.exit()
#!/usr/bin/env python
# -*- coding:utf-8 -*- import sys meau = {
"北京":{
"通州":["梨园","果园","土桥"],
"朝阳":["将台","望京","关庄"],
"海淀":["色色","吸收","里是"]
},
"天津":{
"滨海":["但是","分手","而是"],
"光华":["厚爱","感觉","色鬼"],
"经济":["回来","反对","沟通"]
},
"河北":{
"邯郸":["是啊","在啊","怕看"],
"邢台":["个是","的个","是和"],
"保定":["先动","个他","不发"]
},
} Shi = []
Status = True
try:
while Status:
for k in meau:
print(k)
choose = input("b:back,q:quie,choose:")
if choose in meau:
Shi.append(meau)
meau = meau[choose]
elif choose == "b":
if Shi:
meau = Shi.pop()
elif choose == "q":
Status = False
except TypeError as e:
print(choose)

day1作业脚本的更多相关文章

  1. 自动备份并保存最近几天的SQL数据库作业脚本

    DECLARE @filename VARCHAR(255) DECLARE @date DATETIME SELECT @date=GETDATE() SELECT @filename = 'G:\ ...

  2. Day1作业要求

    Day1作业 作业需求 博客 模拟登录 三级菜单 博客地址 杨振伟Day1博客地址 模拟登录 1.程序说明 实现功能如下 用户输入密码,密码验证后登录成功 用户登录成功后提示登录信息 用户输入3次错误 ...

  3. MS SQL批量生成作业脚本方法介绍总结

    在迁移或升级SQL Server数据库服务器时,很多场景下我们不能还原msdb,所以我们必须手工迁移SQL Server相关作业.如果手工生成每一个作业的脚本话,费时又费力,其实SQL Server中 ...

  4. day1作业--登录入口

    作业概述: 编写一个登录入口,实现如下功能: (1)输入用户名和密码 (2)认证成功后显示欢迎信息 (3)输错三次后锁定 流程图: readme: 1.程序配置文件: 黑名单文件blacklist.t ...

  5. Python3.5 Day1作业:实现用户密码登录,输错三次锁定。

    作业需求: 1.输入用户名密码 2.认证成功后显示欢迎信息 3.输错三次后锁定 实现思路: 1.判断用户是否在黑名单,如果在黑名单提示账号锁定. 2.判断用户是否存在,如果不存在提示账号不存在. 3. ...

  6. day1作业--三级菜单

    作业概述: 写一个三级菜单 实现如下功能: (1)可依次选择进入各子菜单 (2)在每一级按“b”都可以返回上一级,按“q"都可以退出 流程图: readme: 简介: three_menu. ...

  7. day1作业

    作业一:博客 作业二:编写登陆接口 输入用户名密码 认证成功后显示欢迎信息 输错三次后锁定 作业三:多级菜单 三级菜单 可依次选择进入各子菜单 所需新知识点:列表.字典 作业一分析: readme.m ...

  8. day1作业--登录接口

    作业:编写登陆接口 输入用户名密码 认证成功后显示欢迎信息 输错三次后锁定     知识: 1.循环的使用: 2.continue,break在循环中中断的作用: 3.文件的写入,读取: 4.各基础知 ...

  9. day1作业二:多级菜单操作

    作业二:多级菜单 (1)三级菜单 (2)可以次选择进入各子菜单 (3)所需新知识点:列表.字典 要求:输入back返回上一层,输入quit退出整个程序 思路: (1)首先定义好三级菜单字典: (2)提 ...

随机推荐

  1. BZOJ 4300 绝世好题(位运算)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=4300 [题目大意] 给出一个序列a,求一个子序列b,使得&和不为0 [题解] ...

  2. Javascript: Let user select an HTML element like Firebug?综述

    Javascript: Let user select an HTML element like Firebug? Javascript: Let user select an HTML elemen ...

  3. iOS 面试题:OC基本概念题

    1.什么是类和对象? 类是一组具有同样特征和功能的事物的抽象 对象描写叙述了一个物体的特征和行为实现 类是对象的抽象 对象是类的实例 2.OC中定义类,创建对象,使用对象. OC中定义类分为接口部分, ...

  4. Forstner算子

  5. m个相同苹果放的n个相同盘子中的算法

    m个相同的苹果,放在n个相同的盘子中,由于相同,使用排列组合的方法不好处理.这个问题困扰了我很久 最后由大神“或缺”给出了答案: 以8个苹果放在3个盘子中为例 思路: 8苹果3盘子 =8苹果2盘子+5 ...

  6. 基于ZooKeeper的Dubbo简单抽样登记中心

    一:设备zookeeper 系统环境 Ubuntu 14.04.2 LTS x64 IP : 192.168.1.102 下载zookeeper-3.4.6.tar.gz到文件夹/opt.拉开拉链 m ...

  7. paip.数据库发邮件通知配置

    paip.数据库发邮件通知配置 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http://blog.csdn.net/attilax ...

  8. Jquery dom搜索之siblings()方法

    如果给定一个dom的元素集合的算则其对象,siblings()方法允许我们在dom树中搜索这个元素集合的同胞元素,并匹配这些元素构造一个新的对象,Jquery文档里面是这么说的,那么让我来用简单易懂的 ...

  9. Linux内核学习笔记-2.进程管理

    原创文章,转载请注明:Linux内核学习笔记-2.进程管理) By Lucio.Yang 部分内容来自:Linux Kernel Development(Third Edition),Robert L ...

  10. 什么是RAW?

    RAWRAW是一个PHP网站开发系统,使用简单.快捷,核心功能是通过模版组合网站,模版可以自由开发,使开发者不再受传统开发的那种头晕限制,只需要通过填写表单即可完成网站的开发.此外,开发者还可以通过开 ...