使用python写天气预告

先去YY天气注册一个账号,然后就能用API了

http://www.yytianqi.com/

 

  

# encoding=utf-8
import urllib.request
import json
import collections
cityid = 'http://api.yytianqi.com/observe?key=API的key&city=城市ID' 

response = urllib.request.urlopen(cityid) //打开网页
html = response.read().decode('utf-8')//解码为utf-8
info = json.loads(html, object_pairs_hook=collections.OrderedDict)//把json转成python

print(info)

 

 

posted on 2017-11-05 15:57  东京$  阅读(305)  评论(0编辑  收藏  举报

导航