weather_data[weather["name"] ]= weather,怎么理解?

来源:4-4 实操实现:天气预报功能

qq_灰雁_3

2019-04-19 09:23:53

weather_data[weather["name"] ]= weather,怎么理解?


写回答

1回答

时间,

2019-04-19

同学,你好,weather_data[weather["name"] ]= weather,用于存储该城市所对应的天气,weather["name"] 相当于字典中的key值,weather相当于value值。

通过weather["name"] 得到城市的名字,分别为北京,上海,广州,通过weather_data["北京"]= weather对城市进行赋值并保存到字典中。

同学可以在循环中把weather和weather_data打印出来,可以更好的方便理解。

如果我的回答解决了您的疑惑,请采纳!祝学习愉快~~~~~

4

0 学习 · 8160 问题

查看课程