我正在做一个简单的天气应用程序。正如您从下面的代码中看到的,我显示了 5 天的预测,我想显示为列表,但有一个问题,我无法将图像附加到每天的列表元素中。
我的js文件
for (var i = 0; i < 5; i++) {
var li = document.createElement("li");
var iconurl = "https://openweathermap.org/img/w/" + forecast[i].image.toString() + ".png";
var t = document.createTextNode("Date: " + forecast[i].date.toString().substring(8, 10)
+ "/" + forecast[i].date.toString().substring(5, 7) + " "
+ "Current Temperature: " + forecast[i].temperature.toString() + " "
+ "Maximum: " + forecast[i].temperature_max.toString() + " "
+ "Minimum: " + forecast[i].temperature_min.toString() + " "
+ "Description: " + forecast[i].text.toString() + " ");
li.appendChild(t);
document.getElementById("myUL").appendChild(li);
document.getElementById("myInput").value = ""; …
Run Code Online (Sandbox Code Playgroud) 当我使用HashMap时,输出总是像{a,2},而不是我想要输出像(a,2).如何删除花括号或将其修改为")"这个.
wordCount.put("("+'"'+splitted[i].toLowerCase()+'"'+")",
wordCount.getOrDefault(splitted[i], 0) + 1);
Run Code Online (Sandbox Code Playgroud)
而且输出是
{("the")=1, ("be")=1, ("like")=1}
Run Code Online (Sandbox Code Playgroud)
,但我想要这样的输出,
( “the” , 132 )
Run Code Online (Sandbox Code Playgroud)
谢谢.