How can I parse a YAML file in Python

后端 未结 8 1095
醉话见心
醉话见心 2020-11-22 14:54

How can I parse a YAML file in Python?

8条回答
  •  清酒与你
    2020-11-22 15:30

    Example:


    defaults.yaml

    url: https://www.google.com
    

    environment.py

    from ruamel import yaml
    
    data = yaml.safe_load(open('defaults.yaml'))
    data['url']
    

提交回复
热议问题