1、メニュー、省、市や郡のレベルを印刷し
、前に戻って、2
3、いつでもプログラムを終了することができます
インタラクティブバージョン誠心誠意
メニュー= { '北京' { '海淀' { '五道口' { 'SOHO':{ }、 ' 網易':{}、 'Googleの:{}}、
' 中関'{ 'iQIYI' :{}、 '車の家':{}、 'Youkuの':{}}、
'地面に':{ 'Baiduの':{}}
}、
'昌平':{ '川':{ '歳の少年「:{} '北':{}} 'Tiantongyuan':{} 'huilongguan':{}}、
'太陽':{}、
'イースト':{}
}、
「上海':{'閔行":{"人民広場「:{ 'フライドチキン':{}}}、
' 閘北':{ '列車の戦争':{ 'Ctripの':{}}}、'
浦東':{ }
}、
'山東':{}
}
= Trueのタグ
しばらくタグ:
MENU1 = MENU
MENU1の主のためには:#は地方の印刷
プリント(キー)
print('返回上一级请按b,退出系统请按q')
choice1 = input('请输入您想查看的省份>>:').strip() # 查看省份
if choice1 == 'b': # 输入b,则返回上一级
break
if choice1 == 'q': # 输入q,则退出整体
tag = False
print('已退出')
continue
if choice1 not in menu1 : # 输入内容不在mune1内,则继续输入
print('您输入的名字不在系统内,请在以下名单中选择并重新输入')
continue
while tag :
menu2 = menu1[choice1] # 拿到choice1对应的一层字典
for key in menu2:
print(key)
print('返回上一级请按b,退出系统请按q')
choice2 = input('请输入您想查看的地区>>:').strip()
if choice2 == 'b':
break
if choice2 == 'q':
tag = False
print('已退出')
continue
if choice2 not in menu2 :
print('您输入的名字不在系统内,请在以下名单中选择并重新输入')
continue
while tag:
menu3 = menu2[choice2]
for key in menu3:
print(key)
print('返回上一级请按b,退出系统请按q')
choice3 = input('请输入您想查看的商圈>>:').strip()
if choice3 == 'b':
break
if choice3 == 'q':
tag = False
print('已退出')
continue
if choice3 not in menu3 :
print('您输入的名字不在系统内,请在以下名单中选择并重新输入')
continue
while tag:
menu4 = menu3[choice3]
for key in menu4:
print(key)
print('返回上一级请按b,退出系统请按q')
choice4 = input('>>>:').strip()
if choice4 == 'b':
break
if choice4 == 'q':
tag = False
print('已退出')
continue
if choice4 not in menu4:
print('您到底想干嘛')
continue
ストレートの男性バージョンアルゴリズム
メニュー= { '北京' { '海淀' { '五道口' { 'SOHO':{ }、 ' 網易':{}、 'Googleの:{}}、
' 中関'{ 'iQIYI' :{}、 '車の家':{}、 'Youkuの':{}}、
'地面に':{ 'Baiduの':{}}
}、
'昌平':{ '川':{ '歳の少年「:{} '北':{}} 'Tiantongyuan':{} 'huilongguan':{}}、
'太陽':{}、
'イースト':{}
}、
「上海':{'閔行":{"人民広場「:{ 'フライドチキン':{}}}、
' 閘北':{ '列車の戦争':{ 'Ctripの':{}}}、'
浦東':{ }
}、
'山東':{}
}
レイヤー= [メニュー]
真の中に:
current_layer = layers[-1]
for key in current_layer:
print(key)
choice = input('>>: ').strip()
if choice == 'b':
layers.pop(-1)
continue
if choice == 'q':
break
if choice not in current_layer:
continue
layers.append(current_layer[choice])