3-2中文编码报错如何解决?
来源:3-2 如何实现可迭代对象和迭代器对象(2)

Ssunyy
2017-04-20
# -*- 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上运行的,不知道该如何解决?望老师解答,谢谢~~~
写回答
1回答
-
贴一下错误log
042017-04-20