[python] 初学python,级联菜单输出
#Author:shijt china_map = {
"河北": {
'石家庄': ['辛集', '正定', '晋州'],
'邯郸': ['涉县', '魏县', '磁县'],
'衡水': ['饶阳', '安平', '深州']
},
"河南": {
'郑州': ['巩义', '新郑', '登封'],
'开封': ['兰考', '通许', '尉氏'],
'洛阳': ['宜阳', '孟津', '新安']
},
"山西": {
'太原': ['清徐', '阳曲', '古交'],
'大同': ['左云', '大同', '广灵'],
'晋城': ['泽州', '阳城', '泌水']
}
}
exit_flag=False
while not exit_flag:
for i1 in china_map:
print(i1)
choice1=input(">>>choice1:")
if choice1 in china_map:
while not exit_flag:
for i2 in china_map[choice1]:
print("\t"+i2)
choice2 = input("\t>>>choice2:")
if choice2 in china_map[choice1]:
while not exit_flag:
for i3 in china_map[choice1][choice2]:
print("\t\t"+i3)
choice3 = input("\t\t>>>choice3:")
if choice3 in china_map[choice1][choice2]:
print(choice3+"位于"+choice1+choice2)
elif choice3=="b":
break
elif choice3=="q":
exit_flag=True
elif choice2 == "b":
break
elif choice2 == "q":
exit_flag = True
elif choice1 == "q":
exit_flag = True
else:
print("input error")
级联菜单输出
[python] 初学python,级联菜单输出的更多相关文章
- 03 python 初学(字符格式化输出)
#_author: lily #_date: 2018/12/16 name = input("your name: ") age = input("your age: ...
- [python] 初学python,打卡签到
自学python第一周,学了变量和简单的条件判断. 附上猜数游戏代码 #Author:shijt trueAge=40 count=0 while count<3: guessAge=int(i ...
- python 初学笔记 (一)
初学python第一天,希望自己真正了解计算机语言,并且做出成效. 写下学习笔记,记录学习进度,娱乐学习,不断成长. python详细介绍: python是什么?运用到哪里?有哪些在使用它? pyth ...
- 初学 Python(十二)——高阶函数
初学 Python(十二)--高阶函数 初学 Python,主要整理一些学习到的知识点,这次是高阶函数. #-*- coding:utf-8 -*- ''''' 话说高阶函数: 能用函数作为参数的函数 ...
- 初学Python(六)——输入输出
初学Python(六)——输入输出 初学Python,主要整理一些学习到的知识点,这次是输入输出. 输入: # -*- coding:utf-8 -*- ''''' python中的输出为print ...
- 初学Python(一)——数据类型
初学Python(一)——数据类型 初学Python,主要整理一些学习到的知识点,这次是数据类型. #-*- coding:utf-8 -*- #整数 print 1 #浮点数=小数 print 1. ...
- Python初学(1)
最近在学习python,以后想编写一些工作中用的到的脚本.python的入门我选择了<python从初学到入门>,这篇文章我会跟进我的学习进度.算是一个笔记吧. 我本身是熟悉C语言的,看p ...
- 初学Python
初学Python 1.Python初识 life is short you need python--龟叔名言 Python是一种简洁优美语法接近自然语言的一种全栈开发语言,由"龟叔&quo ...
- Python初学的易犯错误
当初学 Python 时,想要弄懂 Python 的错误信息的含义可能有点复杂.这里列出了常见的的一些让你程序 crash 的运行时错误. 1)忘记在 if , elif , else , for , ...
随机推荐
- "remote:error:refusing to update checked out branch:refs/heads/master"的解决办法(转)
https://blog.csdn.net/jacolin/article/details/44014775 在使用Git Push代码到数据仓库时,提示如下错误: [remote rejected] ...
- python获取代理IP并测试是否可用
# coding: utf-8 import urllib2 import re import time def getDL(page): url = 'http://www.xicidaili.co ...
- jira发送邮件报错
jira发送邮件的报错 1.安装完jira后,配置发送邮件出错具体报错如下: An error has occurred with sending the test email: com.atlass ...
- 响应json去除参数值为空的参数-springboot配置
1.添加jackson相关依赖 <!--jackson 开始--><dependency> <groupId>com.fasterxml.jackson.core& ...
- msp430学习笔记-USART
本文引用:http://bbs.ednchina.com/BLOG_ARTICLE_3013784.HTM MSP430F149有两个USART通讯端口,其性能完全一样,每个通讯口可通过RS232和R ...
- 开IE时 暴卡
待打开IE后,在“工具”-“管理加载项”中禁用所有加载项.
- spring 基本配置学习
1.bean的方式说明 作用: 用于配置对象让spring来创建的. 默认情况下它调用的是类中的无参构造函数.如果没有无参构造函数则不能创建成功. 属性: id:给对象在容器中提供一个唯一标识. ...
- 测试教程网.unittest教程.5. 实例: 找出所有是弱密码的用户
From: http://www.testclass.net/pyunit/test_example_3/ 背景 当我们的测试数据是下面这些的时候,我们的用例是有问题的. [ {"name& ...
- 在windows 7中vagrant up 无反应,没任何信息输出
本文转载自:https://blog.csdn.net/cow66/article/details/77993908 我的系统是windows 7 安装了vagrant,当运行vagrant up时, ...
- 【Mysql】mysql使用触发器创建hash索引
概述 若设计的数据表中,包含较长的字段,比如URL(通常都会比较长),查询时需要根据该字段进行过滤: select * from table_xxx where url = 'xxxxxxx'; 为了 ...