weatherToday = "sunny"
weatherTomorrow = "cloudy"
weatherForecast = "Today is going to be " + weatherToday + " and tomorrow will be " + weatherTomorrow + "."
currentTemp = 25
wetaherForecast = weatherForecast + " The current temperature is {:d}.".format(currentTemp)
print(weatherForecast)
为什么这个得出来的不是Today is going to be sunny and tomorrow will be cloudy. The current temperature is 25. 而是Today is going to be sunny and tomorrow will be cloudy.
后面那条字符串拼接最后不是赋给了weatherForecast
,而是赋值给了wetaherForecast
,也就是说你出现了拼写错误,打印的还是上面的拼接结果
有帮助望采纳~
谢谢啊,这习题真无聊啊