Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| dev:python:py-yamal [2016/01/15 13:25] – yoann | dev:python:py-yamal [2021/12/14 22:46] (Version actuelle) – yoann | ||
|---|---|---|---|
| Ligne 6: | Ligne 6: | ||
| ===== Installation ===== | ===== Installation ===== | ||
| + | |||
| + | ==== pip3 ==== | ||
| + | |||
| + | <code bash> | ||
| + | # Crééer/ | ||
| + | source " | ||
| + | |||
| + | # Installer le module via pip | ||
| + | pip3 install pyyaml | ||
| + | </ | ||
| + | |||
| + | ==== tarball ==== | ||
| + | |||
| + | La procédure décrite ci-dessous décrit l' | ||
| Décompresser la tarball: | Décompresser la tarball: | ||
| Ligne 33: | Ligne 47: | ||
| $ sudo deluser yoann staff | $ sudo deluser yoann staff | ||
| </ | </ | ||
| + | |||
| + | ===== Charger un fichier YAML ===== | ||
| + | |||
| + | Pour illustrer le chargement d'un fichier YAML, on crée '' | ||
| + | <file YAML config.yaml> | ||
| + | api: | ||
| + | url: " | ||
| + | port: 8443 | ||
| + | |||
| + | </ | ||
| + | |||
| + | Depuis l' | ||
| + | |||
| + | <code python> | ||
| + | import yaml | ||
| + | |||
| + | with open(' | ||
| + | my_api = yaml.safe_load(file) | ||
| + | |||
| + | type(my_api) | ||
| + | </ | ||
| + | ===== Références ===== | ||
| + | |||
| + | * https:// | ||
| + | |||