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. //Build/ 2014 开发者大会Azure重点整理

     寓教于乐,轻松掌握 Windows Apps和 Cloud //Build/ 2014开发者大会第二天重点整理 (上) //Build/ 2014开发者大会第二天的主题演讲主要包含两部分:Mic ...

  2. 具有 CSA CCM 证明的 SOC 2 可简化 Windows Azure 客户的安全性评估过程

    编辑人员注释:本文章由 Windows Azure 产品市场营销总监 Sarah Fender 撰写. 今天,我们宣布 Microsoft 的公共审计师 Deloitte 已经发布了有关 Window ...

  3. Codeforces 701C They Are Everywhere(Two pointers+STL)

    [题目链接] http://codeforces.com/problemset/problem/701/C [题目大意] 给出 一个字符串,里面包含一定种类的字符,求出一个最短的子串,使得其包含该字符 ...

  4. java常用系统包介绍

    java.applet提供创建 applet 所必需的类和 applet 用来与其 applet 上下文通信的类.java.awt包含用于创建用户界面和绘制图形图像的所有类.java.awt.colo ...

  5. android错误之==与equals的区别

    在做一个电话号码匹配的时候, 开始我使用的是这种情况 if (num == inCall.getNum()) { //操作... } 但是无论如何结果都是false,就算两个号码打印出来一模一样还是f ...

  6. Java程序栈信息文件中的秘密(五)

    最近发现在使用jstack工具在导出Java应用的线程栈时有一个小小的窍门,比如Linux环境上有一个用户为appuser,假如以这个用户启动了一个Java进程B,如果想要导出进程B的线程栈,则必须切 ...

  7. HtmlAgilityPack --解析Html源码

    最近项目需要从网络上抓取一下数据解析Html源码,奈何正则表达式难写,于是网上搜索找到了“ HtmlAgilityPack”类库,敏捷开发,果然效率非同寻常. 在此做笔记,写下心得,顺便给自己总结一下 ...

  8. eclipse修改编译路径

    右击项目--properties--java build path--点击source,修改最下方的路径即可

  9. 面试题之java 编写一个截取字符串的函数,输入为一个字符串和字节数,输出为按字节截取的字符串。 要求不能出现截半的情况

    题目:10. 编写一个截取字符串的函数,输入为一个字符串和字节数,输出为按字节截取的字符串. 但是要保证汉字不被截半个,如"我ABC"4,应该截为"我AB",输 ...

  10. Android adb 命令图解

    做了这么长时间的开发与管理,在命令上总是自见则过,往往却忽视了在其命令上的分享过程,所以现在稍微有点时间就把 其命令的相关操作来简单的扫盲一番吧,也系统通过这种方式去授之以渔而不是鱼,好了,我以图解的 ...