我正在尝试打印每个城市的压力。如何将列表中的元素传递给for循环中的函数
而不是使用列表中的城市,它正在返回一个称为“城市”的城市的压力。
超级新手,无法找到具体的答案。谢谢!!!!!!
import pyowm
owm = pyowm.OWM('eb68e3b0c908251771e67882d7a8ddff')
city = ["tokyo", "jakarta"]
for i in city:
city = owm.weather_at_place('city')
city = city.get_weather()
print (city.get_pressure()['press'])
你为什么命名所有'city'? – roganjosh
另外,你的意思是'city_weather = owm.weather_at_place(i)'? – roganjosh
大声笑,不知道我的意思,编程还是很新的! –