安装yaml
pip install PyYAML
读取
def read_yaml():
path = 'yaml_ini_data.yaml'
# print(path)
file = open(path, 'rb')
result = file.read()
data = yaml.load(result, Loader=yaml.FullLoader)
file.close()
return data
yaml数据类型
list:
- 'list_1'
- 'list_2'
- 'list_3'
- 'list_4'
- 'list_5'
- 'list_6'
dict: 'dict'
复杂字典:
dict_data :
'address': 'test'
'raw' : 'test'
'coinCode': 'test'
'amount': 1000
'betSite':
'21' : 1000
等同于json:
{
"address": "test",
"raw": "test",
"coinCode": "test",
"amount": 1000,
"betSite": {
"test": "1000"
}
}
暂时只用到这几种,其他以后用到再写
本文地址:https://blog.csdn.net/weixin_42132508/article/details/107162171
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
网友评论