a = open('F:\PycharmProjects\study\city_dict1.txt', 'r', encoding='utf8')
date = a.read()
a.close()
menu0 = eval(date)
menu1 = []
menu2 = menu0
while True:
# menu1 = menu1.append(menu0)
for key in menu0:
print(key)
choice = input('>>>:').strip()
if len(choice) == 0: continue
elif choice in menu0:
menu1.append(menu0)
menu0 = menu0[choice]
elif choice == 'q': break
elif choice == 'b':
menu0 = menu1.pop()
elif '+' in choice and len(choice) > 1:
menu0[choice[1:]] = {}
elif '-' in choice and len(choice) > 1:
del menu0[choice[1:]]
else: print('查无此项')
b = open('F:\PycharmProjects\study\city_dict1.txt', 'w', encoding='utf-8')
b.write(str(menu2))
b.close()