• 博客访问： 77127
• 博文数量： 26
• 博客积分： 0
• 博客等级： 民兵
• 技术积分： 250
• 用 户 组： 普通用户
• 注册时间： 2015-08-12 22:31

2016年（26）

2016-11-15 22:18:15

1. #!/usr/bin/env python
2. #_*_ coding:utf-8 _*_
3. import os,sys
5.     pass
6. else:

8. usr_dic = {}
10.     for i in f1:
11.         area_dic = {}
12.         l1 = i.split(':')
13. # usr_dic[l1[0]] = l1[1]
14.         l2 = l1[1].strip('\n').split(' ')
15.         d1 = {}
16.         for i in l2:
17.             l3 = i.split('|')
18. # d1[l3[0]] = l3[1]
19. # print (d1)
20.             l4 = l3[1].split(';')
21.             d2 = {}
22.             for m in l4:
23.                 l5 = m.split('*')
24.                 d2[l5[0]] = l5[1]
25.             d1[l3[0]] = d2
26. # print (d1)
27.         usr_dic[l1[0]] = d1
28. #print (usr_dic)
29. while True:
30.     li_m = []
31.     for m,n in enumerate(usr_dic,1):
32.         print (m,n) #打印出城市和序列号
33.         li_m.append(m)
35.     if city_code in str(li_m):
36.         for m, n in enumerate(usr_dic, 1):
37.             if m == int(city_code):

38.                 while True:
39.                     li_x = []
40.                     for x,y in enumerate(usr_dic[n],1):
41.                         print (x,y) #打印出区信息
42.                         li_x.append(x)
43.                     res_code = input("\033[32mplease input: your 'area_code' or 'b' or 'q'(b:back q:quit):\033[0m")
44.                     if res_code in str(li_x):
45.                         for x,y in enumerate(usr_dic[n],1):
46.                 # print (x,y,usr_dic[n][y])
47.                             if res_code == str(x):

48.                                 while True:
49.                                     li_u = []
50.                                     for u,v in enumerate(usr_dic[n][y],1):
51.                                         print (u,v) #打印出镇的信息
52.                                         li_u.append(u)
53.                                     town_code = input("\033[32mplease input: your 'area_code' or 'b' or 'q'(b:back q:quit):\033[0m")
54.                                     if town_code in str(li_u):
55. # print (town_code)
56.                                         for u, v in enumerate(usr_dic[n][y],1):
57.                                             if u == int(town_code):
58.                                             # print (u,usr_dic[n][y][v])
59.                                                 print (usr_dic[n][y][v]) #打印镇的具体地点信息
60.                                                 sys.exit(0)
61.                                     elif town_code == 'b':
62.                                         break
63.                                     elif town_code == 'q':
64.                                         sys.exit('\033[32mByeBye\033[0m')
65.                                     else:
66.                                         print ('\033[31merror input,please input agin\033[0m')
67.                     elif res_code == 'b':
68.                         break
69.                     elif res_code == 'q':
70.                         sys.exit('\033[32mByeBye\033[0m')
71.                     else:
72.                         print ('\033[31merror input,please input again\033[0m')
73.     elif city_code == 'q':
74.         sys.exit('\033[32mByeBye\033[0m')
75.     else:
76.         print ("\033[31merror input,please input again\033[0m")