for p in provinces:#遍历省级数据
p1 = p.split('|')#list化
url2 = 'http://m.weather.com.cn/data5/city%s.xml'%p1[0]#选定省级代码的城市页面
content2 = urllib2.urlopen(url2).read()#获取相应省的市级数据
city = content2.split(',')#list化
for c in city:
c1 = c.split('|')#list化
url3 = 'http://m.weather.com.cn/data5/city%s.xml'%c1[0]
content3 = urllib2.urlopen(url3).read()#获取相应市的区级数据
area = content3.split(',')#list化
for a in area:
a1 = a.split('|')#list化
f.write(" '"+a1[1]+"'"+": '101"+str(a1[0])+"', ")
f.writelines('}')
f.close()