issue146:python
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédente | Prochaine révisionLes deux révisions suivantes | ||
issue146:python [2019/07/12 12:57] – d52fr | issue146:python [2019/07/12 15:23] – d52fr | ||
---|---|---|---|
Ligne 214: | Ligne 214: | ||
Aussi, si dans la structure de données de réponse[‘currently’] la clé « preciType » est présente, nous l' | Aussi, si dans la structure de données de réponse[‘currently’] la clé « preciType » est présente, nous l' | ||
- | Maintenant, regardons, la manière d' | + | Maintenant, regardons, la manière d' |
+ | |||
+ | Notez que l' | ||
+ | |||
+ | timeout = 10 # 10 second timeout | ||
+ | |||
+ | session = requests.Session() | ||
+ | |||
+ | response = session.get(url, | ||
**Now we have the JSON data structure in our dictionary, just like we read it from the local file earlier. So now, you can comment our four lines that read the local file, and add the lines above. This way, if you want to play some more, you can still work with the local file by commenting out the “live” request code and uncommenting the local file-read code. | **Now we have the JSON data structure in our dictionary, just like we read it from the local file earlier. So now, you can comment our four lines that read the local file, and add the lines above. This way, if you want to play some more, you can still work with the local file by commenting out the “live” request code and uncommenting the local file-read code. | ||
Ligne 221: | Ligne 229: | ||
For those of you who don’t live in the US, and/or don’t use English as your primary language, there are various options for you that keep you from having to write Fahrenheit to Celsius conversion functions, and will present the display text in a language that you want. For example, if you want to see the output in Norwegian, you can pass “nb” within the URL as language and “si” as the units. Below is a modified URL string creation statement that you can use to set things up correctly. Set ‘unitstouse’ as “si” and ‘langtouse’ to ‘nb’. If you want Spanish, use “es”. If you want German, use “de”, and so on. It’s all in the API docs.** | For those of you who don’t live in the US, and/or don’t use English as your primary language, there are various options for you that keep you from having to write Fahrenheit to Celsius conversion functions, and will present the display text in a language that you want. For example, if you want to see the output in Norwegian, you can pass “nb” within the URL as language and “si” as the units. Below is a modified URL string creation statement that you can use to set things up correctly. Set ‘unitstouse’ as “si” and ‘langtouse’ to ‘nb’. If you want Spanish, use “es”. If you want German, use “de”, and so on. It’s all in the API docs.** | ||
+ | |||
+ | Maintenant nous avons la structure de données de JSON dans notre dictionnaire, | ||
+ | |||
+ | J'ai pris le programme de démonstration complètement fonctionnel que j' | ||
+ | |||
+ | Pour ceux qui ne vivent pas aux USA, et/ou dont l' | ||
**Where to go from here? Well, if you go back to the DarkSky API Documentation page I directed you to before, they have a full list of all the keys that are available. They include daily forecasts for the current day plus seven days, hourly forecasts, changing the output language and units of measurements, | **Where to go from here? Well, if you go back to the DarkSky API Documentation page I directed you to before, they have a full list of all the keys that are available. They include daily forecasts for the current day plus seven days, hourly forecasts, changing the output language and units of measurements, | ||
Ligne 227: | Ligne 241: | ||
Start up the Time Machine!** | Start up the Time Machine!** | ||
+ | |||
+ | Où aller à partir de là ? Eh bien, si vous retournez à la page de documentation de l'API DarSky vers laquelle je vous ait dirigé précédemment, | ||
+ | |||
+ | Si vous êtes un « fana de la météo » comme moi, ceci peut être un sujet vraiment amusant. Il devrait être assez facile de mettre ce code dans une interface graphique. Nous pourrions faire cela quelque part dans le futur. | ||
+ | |||
+ | Démarrez la machine à remonter le temps ! | ||
issue146/python.txt · Dernière modification : 2019/07/16 23:06 de andre_domenech