一、参考链接 https://pyyaml.org/wiki/PyYAMLDocumentation 二、python类型转换为yaml # -*- coding: utf-8 -*- # @Time : 2022/1/2 21:53 # @Author : lujunxian # @File : test_yaml.pyimport yamlclass TestYaml(): with open('
一、参考链接
https://pyyaml.org/wiki/PyYAMLDocumentation
二、python类型转换为yaml
# -*- coding: utf-8 -*- # @Time : 2022/1/2 21:53 # @Author : lujunxian # @File : test_yaml.pyimport yamlclass TestYaml(): with open('./data.yaml','w',encoding='utf-8') as f: request={ 'test':{ 'url':'test url', 'username':'test01' }, 'uat':{ 'url':'uat url' } } yaml.dump(request,f)
生成 data.yaml 如下
test: url: test url username: test01uat: url: uat url
三、yaml转换为python类型
with open('./data.yaml','r',encoding='utf-8') as f: print(yaml.safe_load(f))
结果如下
{'test': {'url': 'test url', 'username': 'test01'}, 'uat': {'url': 'uat url'}}
360可以有效防止黑客攻击密码
360可以有效防止黑客攻击密码