环境准备

     使用python来对yml文件内容进行读写操作,然后在shell中调用python

     shell动态修改yml配置文件

    shell动态修改yml配置文件

 编写python脚本

import yaml

with open("config/application.yml",'r') as f:
        result = f.read()
        x=yaml.load(result,Loader=yaml.FullLoader)
        print(x["spring"]["datasource"]["url"])

        x["spring"]["datasource"]["url"]="http://wwww.baidu.com"
        with open("config/application.yml",'w') as w_f:
                yaml.dump(x,w_f)
python2

相关文章:

  • 2021-09-16
  • 2022-12-23
  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-28
  • 2022-12-23
  • 2022-12-23
  • 2021-06-28
  • 2022-12-23
  • 2022-01-21
相关资源
相似解决方案