# -*- coding: utf-8 -*-
import sys, urllib
import json,os
url="http://api.k780.com:88/?app=weather.today&weaid=101110901&&appkey=16581&sign=5a7a4859606b2d638bd7f6f5a22d4be9&format=json"
wp = urllib.urlopen(url) 
content = wp.read()
a=json.loads(content)
a=a["result"]
s=a["days"]+"   "+a["week"]+"   "+a["citynm"]+"   "+a["weather"]+"   "+a["temperature"]+"   "+a["humidity"]+"   "+a["winp"]+"   "+a["wind"]
s=s.encode("utf8")

print s
fp = open("/home/pi/xiangmu/tianqi/tianqi.txt","wb") 
fp.write(s)
fp.close()

url = "http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&text="+s+"湿度"+a["humidity"].encode("utf8")
wp = urllib.urlopen(url) 
content = wp.read()
fp = open("/home/pi/xiangmu/tianqi/tianqi.mp3","wb") 
fp.write(content) 
fp.close() 
os.system("omxplayer /home/pi/xiangmu/tianqi/tianqi.mp3")






    
