#!/usr/bin/python
# -*- coding: UTF-8 -*-
import json
import smtplib
import urllib
from email.mime.text import MIMEText
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html.decode("utf-8")
str = getHtml("http://api.map.baidu.com/telematics/v3/weather?location=沈阳&output=json&ak=Dy2Zop7tjKlj2EZxwe88Hbjz")
_json = json.loads(str)["results"]
_json = _json[0]["weather_data"];
print("沈阳天气:".decode("utf-8"))
for i in range(0, 4):
print(_json[i]["date"] + " " + _json[i]["weather"] + " " + _json[i]["wind"] + " " + _json[i]["temperature"]);