标签:pairs pen 打开 pytho urllib utf-8 技术分享 2-2 http
先去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)
标签:pairs pen 打开 pytho urllib utf-8 技术分享 2-2 http
原文地址:http://www.cnblogs.com/haq5201314/p/7787638.html