问答详情
源自:5-4 实现未来3天天气预报查询功能

大佬们,这个为啥会报错呀

大佬们,这个为啥会报错呀http://img2.mukewang.com/61e835bb000120af28001608.jpg

提问者:王小east 2022-01-20 00:01

个回答

  • Ai_Cliare
    2023-05-04 15:45:59

    修改w3d 方法代码部分截图: 

    http://img3.mukewang.com/6453629900015c8521781384.jpg

  • Ai_Cliare
    2023-05-04 15:43:00

    我执行3天的方法会报错,可能因为接口返回数据有变化。我自己重新修改了一下w3d 的方法,仿照w24h方法。才获得数据。具体修改如下,仅供参考:

    List<DayWeather> (String appCodeString area) {
        List<DayWeather> resultList = ArrayList<DayWeather>(){
            OkHttpClient client = OkHttpClient()Request request = Request.Builder()
                    .get()
                    .url(+ area)
                    .header(+ appCode)
                    .build()Call call = client.newCall(request)Response response = call.execute()Gson gson = GsonBuilder()
                    .setFieldNamingPolicy(FieldNamingPolicy.)
                    .create()String resBody = response.body().string()Map result = gson.fromJson(resBodyTypeToken<Map>() {
            }.getType())List<Map<StringString>> dayList = .getValue(resultArrayList.)(dayList == || dayList.size() == ){
                ArrayList<DayWeather>()}
            (Map<StringString> day : dayList) {
                (i=i <=i++){
                    DayWeather dayWeather = DayWeather()dayWeather.setYear(day.get().substring())dayWeather.setMonth(day.get().substring())dayWeather.setDay(day.get().substring())dayWeather.setDayAirTemperature(day.get())dayWeather.setNightAirTemperature(day.get())dayWeather.setDayWeather(day.get())dayWeather.setNightWeather(day.get())dayWeather.setDayWindPower(day.get())dayWeather.setNightWindPower(day.get())resultList.add(dayWeather)}
            }
            } (Exception e) {
            RuntimeException(e)}
        resultList}


  • weixin_慕沐8275724
    2022-01-26 01:35:00

    首先把第一个年那个去掉,只有8条数据,需要8个空白就行;

    其次正确格式是%s  不是s%.

    我只能看到这些。