Traditional Culture Encyclopedia - Weather forecast - How to use python and api to get weather forecast

How to use python and api to get weather forecast

Try this: /weather_mini? city key = 10 12 10 10 1

The returned data is compressed by gzip. If you use urllib, you need to decompress the obtained binary data before decoding it into a string. It is much more convenient to use the requests library, including coding, which will automatically help you solve it, so you don't need to worry about it yourself.

By the way, I recommend Chrome's JSON-Handle plug-in. It's very convenient to view JSON.