#!/usr/bin/env python # -*- encoding: utf-8 -*- """ @Contact : liuyuqi.gov@msn.cn @Time : 2024/04/30 @License : Copyright © 2017-2022 liuyuqi. All Rights Reserved. @Desc : yaml read and write """ import yaml def read_yaml(file_path): with open(file_path, 'r') as file: data = yaml.load(file, Loader=yaml.FullLoader) return data def write_yaml(file_path, data): with open(file_path, 'w') as file: yaml.dump(data, file) if __name__=='__main__': data = { "owner": "xx", "token": "xx", "repo": "xx", "secret": [ { "key": "xx", "value": "xx" }, { "key": "x", "value": "xx" } ] } write_yaml("account.example.yml", data)