# print data["success"]
result =data["result"]
# print result
for i in range(16,2651):
print i
for rel in result[str(i)]:
result2[result[str(i)]['citynm']]=result[str(i)]['cityid']
# print result2
print result2
# print result2
1Traceback (most recent call last):6
File "F:\PythonTest\CheckWeather.py", line 23, in <module>
for rel in result[str(i)]:
KeyError: '16'
[Finished in 0.9s]作者: x8344364 时间: 2017-10-28 23:31
我知道了,键值在字典中不存的,要加个判断语句!!