|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- while True:
- for key in menu:
- print(key)
- choice = input('>>:').strip()
- if choice in menu:
- for key2 in menu[choice]:
- print(key2)
- choice2 = input('>>:').strip()
- if choice2 in menu[choice]:
- for key3 in menu[choice2]:
- print(key3)
复制代码- D:\wolf\test\venv\Scripts\python.exe D:/wolf/test/test.py
- 省1
- 省2
- 省3
- >>:省1
- 市1
- 市2
- 市3
- >>:市1
- Traceback (most recent call last):
- File "D:/wolf/test/test.py", line 66, in <module>
- for key3 in menu[choice2]:
- KeyError: '市1'
复制代码
输入市的时候就有这个错误是什么意思啊。
if choice2 in menu[choice]:
for key3 in menu[choice2]:
print(key3)
menu[choice2]:
想想这个字典是什么
你就知道答案了
|
|