# 一、元素分类
# 有如下值集合[11, 22, 33, 44, 55, 66, 77, 88, 99, 90...],将所有大于
#
# 的值保存至字典的第一个key中,将小于
#
# 的值保存至第二个key的值中。
# 即: {'k1': 大于66的所有值, 'k2': 小于66的所有值}
# a = [11,22,33,44,55,66,77,88,99]
# b = []
# c = []
# dict = {"k1":b,"k2":c}
# for i in a:
# if i >66:
# b.append(i)
# if i <66:
# c.append(i)
# print(dict)
# 二、查找
# 查找列表中元素,移除每个元素的空格,并查找以a或A开头并且以c结尾的所有元素。
# li = ["alec", " aric", "Alex", "Tony", "rain"]
# tu = ("alec", " aric", "Alex", "Tony", "rain")
# dic = {'k1': "alex", 'k2': ' aric', "k3": "Alex", "k4": "Tony"}
# for i in li:
# i = i.strip()
# if (i.startswith('A') or i.startswith('a')) and i.endswith('c') :
# print(i)
# for i in tu:
# i = i.strip()
# if (i.startswith('A') or i.startswith('a')) and i.endswith('c') :
# print(i)
# for i in dic.values():
# i = i.strip()
# if (i.startswith('A') or i.startswith('a')) and i.endswith('c'):
# print(i)
# 三、输出商品列表,用户输入序号,显示用户选中的商品
# 商品
# li = ["手机", "电脑", '鼠标垫', '游艇']
# while True:
# choice=int(input('请输入序号:'))
# print(li[choice])
# 四、购物车
# 功能要求:
# 要求用户输入总资产,例如:2000
# 显示商品列表,让用户根据序号选择商品,加入购物车
# 购买,如果商品总额大于总资产,提示账户余额不足,否则,购买成功。
# 附加:可充值、某商品移除购物车
# goods = [
# {"name": "电脑", "price": 1999},
# {"name": "鼠标", "price": 10},
# {"name": "游艇", "price": 20},
# {"name": "美女", "price": 998},
# ]
# shopping_cart=[]
# flag=True
# sum=0
# while flag:
# money=input("请输入您的账户金额:").strip()
# if money.isdigit():
# money=int(money)
# print("商品列表:")
# while flag:
# for i in range(len(goods)):
# print(i+1,goods[i]["name"],goods[i]["price"])
# choice=input("请选择您需要购买的商品或退出(q):").strip()
# num=0
# if choice.isdigit():
# choice=int(choice)
# choice=choice-1
# if choice >=0 and choice <len(goods):
# if money > goods[choice]['price']:
# product=goods[choice]
# if product in shopping_cart:
# num+=1
# else:
# shopping_cart.append(product)
# money = money - goods[choice ]["price"]
# sum+=goods[choice ]["price"]
# print("购买成功,您购买了"+goods[choice]['name'],'您还剩'+str(money)+'元钱')
# elif money<goods[choice]['price']:
# print("对不起,您的账户余额不足!")
# flag=False
# else:
# print('商品不存在')
# continue
# elif choice.lower()=='q':
# print('---购物清单---:')
# for k,v in enumerate(shopping_cart,1):
# print(k,v['name'],v['price'],num)
# print('共消费'+str(sum)+'元'+'\n您的余额是'+str(money)+'元'+'\n---结束购物---')
# flag=False
# else:
# print('请输入数字或q')
# continue
# else:
# print('请输入数字')
# continue
# 选做题:用户交互,显示省市县三级联动的选择
dic = {
"河北": {
"石家庄": ["鹿泉", "藁城", "元氏"],
"邯郸": ["永年", "涉县", "磁县"],
},
"河南": {
'a':[1,2,3],
'c':[4,5,6] },
"山西": {
'd':[7,8,9],
'e':[10,11,12]
}
}
# 第一种
# flag=True
# while flag:
# for i in dic:
# print(i)
# choice1=input('>>:').strip()
# if choice1.upper()=='Q':
# break
# next1=dic[choice1]
# for j in next1:
# print(j)
# while flag:
# choice2=input('>>:').strip()
# if choice2.upper()=='Q':
# break
# if choice2.upper()=='B':
# flag=False
# break
# next2=next1[choice2]
# for z in next2:
# print(z)
# choice3 = input('>>:').strip()
# if choice3.upper()=='Q':
# flag=False
# break
# if choice3.upper()=='B':
# continue
exit_flag = False
while not exit_flag:
for key in dic:
print(key) choice = input(">:").strip()
if len(choice) == 0 : continue
if choice == 'q':
exit_flag = True
continue
if choice in dic: #省存在,进入此省下一级
while not exit_flag:
next_layer = dic[choice]
for key2 in next_layer:
print(key2)
choice2 = input(">>:").strip()
if len(choice2) == 0: continue
if choice2 == 'b': break
if choice2 == 'q':
exit_flag = True
continue
if choice2 in next_layer: #再进入下一层
while not exit_flag:
next_layer2 = next_layer[choice2]
for key3 in next_layer2:
print(key3)
choice3 = input(">>>:").strip()
if len(choice3) == 0: continue
if choice3 == 'b': break
if choice3 == 'q':
exit_flag = True
continue if choice3 in next_layer2:
while not exit_flag:
next_layer3 = next_layer2[choice3]
for key4 in next_layer3:
print(key4) choice4 = input(">>>>:").strip()
if choice4 == 'b':break
if choice4 == 'q':
exit_flag = True
continue # 第二种
# current_layer=dic
# layers=[dic]
# while True:
# for i in current_layer:
# print(i)
# choice=input('>>>:').strip()#用户输入选项
# #判断输入是否有效
# if choice in current_layer:
# layers.append(current_layer)#把当前层菜单添加到全部层,用于返回上一级使用
# current_layer=current_layer[choice]#把当前层替换新的
# elif choice.upper()=='B':
# current_layer=layers[-1]
# layers.pop()
# elif choice.upper()=='Q':
# break

s5_day3作业的更多相关文章

  1. python10作业思路及源码:类Fabric主机管理程序开发(仅供参考)

    类Fabric主机管理程序开发 一,作业要求 1, 运行程序列出主机组或者主机列表(已完成) 2,选择指定主机或主机组(已完成) 3,选择主机或主机组传送文件(上传/下载)(已完成) 4,充分使用多线 ...

  2. SQLServer2005创建定时作业任务

    SQLServer定时作业任务:即数据库自动按照定时执行的作业任务,具有周期性不需要人工干预的特点 创建步骤:(使用最高权限的账户登录--sa) 一.启动SQL Server代理(SQL Server ...

  3. 使用T-SQL找出执行时间过长的作业

        有些时候,有些作业遇到问题执行时间过长,因此我写了一个脚本可以根据历史记录,找出执行时间过长的作业,在监控中就可以及时发现这些作业并尽早解决,代码如下:   SELECT sj.name , ...

  4. T-SQL检查停止的复制作业代理,并启动

        有时候搭建的复制在作业比较多的时候,会因为某些情况导致代理停止或出错,如果分发代理时间停止稍微过长可能导致复制延期,从而需要从新初始化复制,带来问题.因此我写了一个脚本定期检查处于停止状态的分 ...

  5. Python09作业思路及源码:高级FTP服务器开发(仅供参考)

    高级FTP服务器开发 一,作业要求 高级FTP服务器开发 用户加密认证(完成) 多用户同时登陆(完成) 每个用户有不同家目录且只能访问自己的家目录(完成) 对用户进行磁盘配额,不同用户配额可不同(完成 ...

  6. 个人作业week3——代码复审

    1.     软件工程师的成长 感想 看了这么多博客,收获颇丰.一方面是对大牛们的计算机之路有了一定的了解,另一方面还是态度最重要,或者说用不用功最重要.这些博客里好些都是九几年或者零几年就开始学习编 ...

  7. 个人作业-week2:关于微软必应词典的案例分析

    第一部分 调研,评测 评测基于微软必应词典Android5.2.2客户端,手机型号为MI NOTE LTE,Android版本为6.0.1. 软件bug:关于这方面,其实有一些疑问.因为相对于市面上其 ...

  8. 软件工程第二次作业——git的使用

    1. 参照 http://www.cnblogs.com/xinz/p/3803109.html 的第一题,每人建立一个GitHub账号,组长建立一个Project,将本组成员纳入此Porject中的 ...

  9. hadoop作业调度策略

    一个Mapreduce作业是通过JobClient向master的JobTasker提交的(JobTasker一直在等待JobClient通过RPC协议提交作业),JobTasker接到JobClie ...

随机推荐

  1. flutter datatable

    最后,还是用到了 PaginatedDataTable 我把header改成了最终条件显示. 主要是要有listview之类的scrollview容器,否则会报错. 切换页的时候,记得加入空行,否则会 ...

  2. 开启GitHub模式,now!

    (原文地址为:http://www.karottc.com/blog/2014/06/15/current-doing/) 最近看到了一篇文章,该文章的作者将自己连续177天在github上commi ...

  3. Unicode UTF-8 转换

    Unicode是类似“U+4E25”或“\u4E25”的编码方式,很多情况下是4个十六进制的数,有时候不止. Unicode编码系统可分为编码方式和实现方式两个层次: 编码方式:“严”的Unicode ...

  4. improve deep learning network 课程笔记

    公开课笔记 Bias & variance bias: 1. more epoch 2. deeper network 3.hyperparameters variance : larger ...

  5. (转)使用 python Matplotlib 库绘图

    运行一个简单的程序例子: import matplotlib.pyplot as plt plt.plot([1,2,3]) plt.ylabel('some numbers') plt.show() ...

  6. hdu 2074 叠筐 好有意思的绘图题

    叠筐 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...

  7. 简单的php基于curl的反向代理程序

    起因: 经理:需要实现一个反向代理? 我:  简单,nginx分分钟配置好. 经理:嗯?没有nginx? 我: nodejs也行啊,网上有例子分分钟搞定. 经理:嗯?只有虚拟主机,只能上传php程序? ...

  8. 在Windows端安装kafka 提示错误: 找不到或无法加载主类 的解决方案

    在配置好kafka的server.properties文件后,cmd进入命令窗口输入命令:.\bin\windows\kafka-server-start.bat config\server.prop ...

  9. C语言数据类型大小

    数据类型大小是由操作系统和编译器共同决定的,但必须满足: short和int至少为16bit:long至少为32bit: short不能超过int,int不能超过long. 在主流编译器中,32位机和 ...

  10. Linux下的Make与Makefile

    原文转载自:http://www.cpplive.com/html/1776.html 另外一个不错的博客http://bbs.chinaunix.net/thread-1950588-1-1.htm ...