首先我很抱歉因为我的英文太糟糕了。我有一个问题,我怎么知道是下雨还是下雪?我尝试通过temp检查,但它不对。我从openweathermap API获取数据。 这是我的codepen: http://codepen.io/khanh1993/full/EybPXG/ 以及检查的条件:
if(fTemp>80){
$("#icon").html('<i class="fa fa-sun-o fa-fw fa-5x fa-spin" aria-hidden="true"></i>');
$('body').css("background","url('http://www.walldevil.com/wallpapers/a79/nature-backgrounds-screen-desktop-savers-high-sunshine-wallpapers-images-resolution.jpg')")
}
else if(fTemp>58){
$("#icon").html('<i class="fa fa-tint fa-fw fa-5x" aria-hidden="true"></i>');
$('body').css("background","url('http://wallpapercave.com/wp/doNuhh5.jpg')");
}
else if(fTemp>40){
$('#icon').html('<i class="fa fa-cloud fa-5x fa-fw" aria-hidden="true"></i>');
$('body').css("background","url('http://eskipaper.com/images/cloud-background-6.jpg')");
}
答案 0 :(得分:0)
这是我在openweather API中找到的API文档
const int DATA_SIZE = 20;
int data[DATA_SIZE] = {0};
// Initialize and print array
init_array(data, DATA_SIZE, 100);
print_array(data, DATA_SIZE);
// Find maximum value
int max = find_max(data, DATA_SIZE);
cout << "max = " << max << endl;
return 0;
您可以从{"coord":{"lon":139,"lat":35},
"sys":{"country":"JP","sunrise":1369769524,"sunset":1369821049},
"weather":[{"id":804,"main":"clouds","description":"overcast clouds","icon":"04n"}],
"main":{"temp":289.5,"humidity":89,"pressure":1013,"temp_min":287.04,"temp_max":292.04},
"wind":{"speed":7.31,"deg":187.002},
"rain":{"3h":0},
"clouds":{"all":92},
"dt":1369824698,
"id":1851632,
"name":"Shuzenji",
"cod":200}
这是我如何得到
response.weather[0].main
现在输出将是“Rain”