为了账号安全,请及时绑定邮箱和手机立即绑定

世界天气在线,pywwo软件包安装错误

世界天气在线,pywwo软件包安装错误

慕尼黑5688855 2022-08-25 15:07:33
我正在尝试使用世界天气在线数据。在说明中,给出了我需要使用包。但是,当我第一次运行时,它给了我“无效的语法错误,即使没有。我该如何处理?谢谢。pywwopip install pywwo
查看完整描述

2 回答

?
牧羊人nacy

TA贡献1862条经验 获得超7个赞

我不认为pywwo再有效了。我使用的是pyowm,而不是:https://pyowm.readthedocs.io/en/latest/。您将需要一个API密钥;按照这个得到一个:https://openweathermap.org/appid。


然后,您可以编写一个函数来获取温度,如下所示:


def get_temp(zipcode:str)->int:

    """function to get weather using zipcode through pyOWM

    Arguments:

        zipcode {str} -- given by the user

    Returns:

        int -- temperature in fahrenheit returned by pyOWM

                for the current zipcode at the current time

    """

    owm = pyowm.OWM('YOUR API KEY GOES HERE')  # API key

    observation = owm.weather_at_zip_code(zipcode, "us")

    current_weather = observation.get_weather()

    temperature = current_weather.get_temperature('fahrenheit')['temp']

    return temperature


查看完整回答
反对 回复 2022-08-25
?
料青山看我应如是

TA贡献1772条经验 获得超8个赞

您可以 git 克隆存储库,然后它们将导入到您的项目中。

我阅读了文档,没有找到关于点数的信息。试试上面的方式。


查看完整回答
反对 回复 2022-08-25
  • 2 回答
  • 0 关注
  • 192 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号