# -*- coding:utf-8 -*-
__author__ = 'yangxin_ryan'
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import json
import requests
import time
from util.wechat import WeChat
class Weather(object):
def run(self):
url = "http://wthrcdn.etouch.cn/weather_mini?city=北京"
response = requests.get(url)
weather_data = json.loads(response.text)
print(weather_data)
date = time.strftime('%Y-%m-%d', time.localtime(time.time()))
year = str(date).split("-")[0]
month = str(date).split("-")[1]
day = weather_data['data']['forecast'][0]['date']
city = weather_data['data']['city']
weather_high = weather_data['data']['forecast'][0]['high']
weather_low = weather_data['d
Python实现获取当前天气
最新推荐文章于 2025-06-22 18:51:48 发布
