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 [2017/12/26 08:10] – yoann | dev:python:py-yamal [2021/12/14 22:46] (Version actuelle) – yoann | ||
---|---|---|---|
Ligne 7: | Ligne 7: | ||
===== Installation ===== | ===== Installation ===== | ||
- | La procédure décrite ci-dessous décrit l' | + | ==== 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 35: | 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:// | ||
+ |