当前位置:网站首页>Addition, deletion, modification and query of ymal file

Addition, deletion, modification and query of ymal file

2022-06-27 01:40:00 xxs!

yaml Introduce :
A data format , Support comments , Line break , Multiline string

Way of use :
Generally, it can be used as a configuration file (conf file ) Record account information , Environmental Science , database , Interface related parameters, etc

Usage method :
1、 Read yaml file

import yaml
  """ Read configuration file """
    with open(read_path() + "/conf/config.yaml") as f:
        data = yaml.safe_load(f)
    return data

2、 modify yaml Data in the file

  with open(read_path() + "/conf/config.yaml", 'w') as f:
         yaml.dump(data, f, default_flow_style=False)

3、 newly added yaml Data in the file

       with open(read_path() + "/conf/config.yaml", "a") as f:
            yaml.dump(desired_caps, f)
原网站

版权声明
本文为[xxs!]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/178/202206270121098542.html