1、用户登录,输入3次密码错误锁定
2、三级菜单
#!/usr/bin/env python
#-*- coding:utf-8 -*-
user = 'wuyanzu'
passwd = 'shajiba'
for i in range(3):
username = input("username:")
password = input("password:")
if user == username and passwd == password:
print("welcome login...")
break
else:
print("user or password is error")
if i == 2:
print("Account is locked,byebye!")
#!/usr/bin/env python
#-*- coding:utf-8 -*-
menu = {
"火车":{"四川省":
{"达州站":{},"成都站":{},"内江站":{}},
"湖南省":
{"岳阳站":{},"长沙站":{}}},
"地铁":{"1号线":
{"天府广场":{},"世纪城":{},"升仙湖":{}},
"2号线":
{"龙泉":{},"犀浦":{},"春熙路":{}}},
"公交":{"53路":
{'太平村':{},'总府路':{},'曹家巷':{}},
"34路":
{'人民北路':{},'磨子桥':{},'青羊宫':{}}}
}
record =[]
while True:
for key in menu:
print(key)
your_choice = input("your choice >>:").strip()
if your_choice in menu:
record.append(menu)
menu = menu[your_choice]
elif your_choice == 'b':
if record:
menu = record.pop()
elif your_choice == 'q':
exit()
else:
print("\033[34;1m输入有误,请重新输入\033[0m")