今天调python代码,出错代码
temp_min = weather_data[time_index]['low'],
temp_max = weather_data[time_index]['high']
description = weather_data[time_index]['text'].replace('/', u'转')
wind_deg = weather_data[time_index]['wind']
response = city_name + time_name + description + u',' + wind_deg + u',' + u'最高温度' + temp_max+ u'>摄氏度,' + u'最低温度' + temp_min + u'摄氏度'
coercing to Unicode: need string or buffer, tuple found
怎么会有tuple冒出来?看着+操作符两边都是字符串啊!百思不得其解,最后突然想起+操作符会抛出异常,改用%操作符输出
response = u'%s%s%s,%s,最高温度%s摄氏度,最低温度%s摄氏度'%(city_name, time_name, description, wind_deg, temp_max, temp_min)
西安今天小雨转阴,微风小于3级,最高温度27摄氏度,最低温度(u'22',)摄氏度