Python获取天气预报代码示例
时间: 2023-11-05 08:34:13 浏览: 17
微信小程序 天气预报开发实例代码
5星 · 资源好评率100%
可以参考下面的代码示例,使用 Python 来获取天气预报:import requests# Get the response from OpenWeatherMap
response = requests.get('http://api.openweathermap.org/data/2.5/weather?q=London,uk')# Convert the response to a Python dictionary
weather_data = response.json()# Get the temperature from the dictionary
temperature = weather_data['main']['temp']
阅读全文