# -*- coding:utf-8 -*-
import requests
def getweather(city):
r = requests.get(u'http://wthrcdn.etouch.cn/weather_mini?city=' + city)
data = r.json()['data']['forecast'][0]
return '%s: %s,%s' %(city, data['low'], data['high'])
print getweather('北京').encode('utf8')
print getweather(u'长春')
看了之前老师的解答改成了print getweather('北京').encode('utf8')形式,还是报错,我是在pycharm上运行的,不知道该如何解决?望老师解答,谢谢~~~
登录后可查看更多问答,登录/注册