【问题标题】:Open Weather Map api key not working (i guess)打开天气地图 api 密钥不起作用(我猜)
【发布时间】:2019-09-22 19:23:37
【问题描述】:

前段时间,我创建了一个程序,使用 pyowm 模块告诉你你所在城市的当前温度,它运行良好,直到现在

我认为这可能是您从网站获得的 API 密钥的原因,所以我生成了新密钥,但它仍然无法正常工作

owm = pyowm.OWM('my API key') # doesn't work beyond this point
data = Get_Location() # gets your current location
location = data[4] # city name

weatherloc = owm.weather_at_place(location)
status = weatherloc.get_weather()
temperature = status.get_temperature('celsius')['temp']
weather = status.get_detailed_status()
main_weather = status.get_status()
temp_out = f"and outside temperature is {temperature}{degree} celsius."
print(temp_out)

这是非常基本的东西,但程序只是在“owm”行之后停止,没有错误消息或任何东西,它只是停止

编辑:显示代码时忘记放“打印”

【问题讨论】:

  • 你希望这段代码做什么?如果你想输出temp_out,那么你可以用print(temp_out)来做到这一点
  • 我希望它能像今天一样工作,但它只是在第一行之后停止,我在这些行之间放了一些随机打印以查看问题出在哪里,发现它在“owm”之后= pyowm.OWM('我的 API 密钥')"

标签: python openweathermap


【解决方案1】:

您是否尝试过使用请求模块?它花费的代码比这要短得多

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多