- 帖子
- 2
- 精华
- 0
- 积分
- 9
- 阅读权限
- 10
- 注册时间
- 2017-10-28
- 最后登录
- 2017-10-29
|
#coding:utf-8
import urllib2
url1 = 'http://api.k780.com:88/?app=weather.city&&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json'
content = urllib2.urlopen(url1).read()
# print content
import json
data = json.loads(content)
# print data
result2={}
# print result2
# 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] |
|