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

我正在尝试使用世界天气在线数据。在说明中,给出了我需要使用包。但是,当我第一次运行时,它给了我“无效的语法错误,即使没有。我该如何处理?谢谢。pywwopip install pywwo



慕尼黑5688855
浏览 193回答 2
2回答

牧羊人nacy

我不认为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

料青山看我应如是

您可以 git 克隆存储库,然后它们将导入到您的项目中。我阅读了文档,没有找到关于点数的信息。试试上面的方式。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python