设为首页 加入收藏

TOP

Python代码之三级登录
2017-10-09 16:53:52 】 浏览:5476
Tags:Python 代码 三级 登录
# -*- coding:utf-8 -*-
#Author:Mr Gan

china_map ={
"华南区":
{
"广东省":{"广州市":["越秀区","天河区"],"东莞市":["哥台区","沧桑区"]},
"海南省":{"海口市":["龙河区","丰台区"],"三亚市":["苍山区","晋安区"]}
},
"华北区":
{
"河北省":{"石家庄市":['台州区','河内区'],"唐山市":['台南区','雄安区']}
}}
while True:
for i in china_map:#遍历第一级key
print(i)
choice_1 = input("选择进入》》:")
if choice_1 in china_map:
while True:
for i2 in china_map[choice_1]:#遍历第二级key
print("\t\t",i2)
choice_2 = input("选择进入》》:")
if choice_2 == "q":
break
if choice_2 in china_map[choice_1]:
while True:
for i3 in china_map[choice_1][choice_2]:#遍历第三级key
print("\t\t\t\t", i3)

choice_3 = input("选择进入》》:")
if choice_3 == "q":
break
if choice_3 in china_map[choice_1][choice_2]:
while True:
for i4 in china_map[choice_1][choice_2][choice_3]:
print("\t\t\t\t\t\t",i4)
choice_4 = input("最后一层,按q返回:")
if choice_4 == "q":
break
else:
pass

代码有点low
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇python __name__ 变量的含义 下一篇Python代码之登录接口

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目