import yaml
def test_yaml():
# 要生成yaml的文件内容
env = {
"default": "dev",
"testing-studio": {
"dev": "127.0.0.1:80",
"test": "127.0.0.2222:80"
}
}
# w:写权限
# f:文件
with open("env.yaml", "w") as f:
yaml.safe_dump(data=env, stream=f)
生成后的yaml文件: