#!\usr\bin\env\python
# -*- coding:utf - 8 -*9
# Author:Alex hua
university_list = { # 大学列表
"安徽省": {
"合肥": ["中国科技大学", "合肥工业大学"],
"安庆": ["安庆学院"],
"阜阳": ["阜阳学院"]
},
"江苏省": {
"南京": ["南京大学", "南京工业大学"],
"南通": ["南通大学"],
"苏州": ["苏州大学"],
},
"浙江省": {
"杭州": ["浙江大学", "杭州电子科技大学"],
"宁波": ["宁波大学"],
"嘉兴": ["嘉兴学院"],
}
}
flag = True
try_province = 0
try_city = 0
try_school = 0
while flag:
if try_province<3:
province_str1="欢迎进入沿海省份"
print(province_str1.center(20,'-'))
for province in university_list.keys():
print(province)
print("-----------------------------")
province_input = input("请输入省份:")
city_flag = True
while city_flag:
if try_city<3:
if province_input.strip() in university_list:
print("欢迎进入:%s!" % (province_input,)) #赋值,一定要打逗号
city_str2 = "欢迎进入中国地区"
print(city_str2.center(20,'-'))
for city in university_list[province_input].keys():
print(city)
print("--------------------")
city_input=input("请输入中国城市:")
school_flag = True
while school_flag:
if try_school<3:
if city_input.strip() in university_list[province_input]:
print("欢迎进入: %s!" % (city_input,))
school_str3="欢迎进入中国学校"
print(school_str3.center(20,'-'))
for school in university_list[province_input][city_input]:
print(school)
print("----------------------")
school_input=input("请输入学校名称")
if school_input.strip() in university_list:
print("欢迎进入: %s!" % (school_input,))
print("当前位置:%s--%s--%s" % (province_input, city_input, school_input,))
print("已经结束了")
flag =False
city_flag=False
school_flag=False
break
else:
print("你输入学校信息有误,请重新输入")
try_school+=1
else:
print("你输入城市信息有误,请重新输入")
try_city+=1
school_flag = False
else:
print("输入超过三次,返回执行")
flag=False
city_flag=False
school_flag=False
else:
print("输入省份信息有误,请重新输入")
try_province +=1
city_flag=False
else:
print("输入三次,返回执行")
flag=False
city_flag =False
else:
print("输入超过三次,返回执行")
flag=False