xxxxxxxxxx
import yaml
# Read the YAML file
with open('file.yml', 'r') as file:
# Parse the YAML data
data = yaml.load(file, Loader=yaml.FullLoader)
# Access the parsed data
for key, value in data.items():
print(key, value)
xxxxxxxxxx
pip install pyyaml
import yaml
with open("example.yaml", 'r') as stream:
try:
print(yaml.safe_load(stream))
except yaml.YAMLError as exc:
print(exc)