1、yaml 基本语法
- 大小写敏感;缩进表示层级关系;缩进不允许用tab,使用空格;#表示注释
- 包含类似python的字典与列表数据类型
- 纯量包括:字符串、布尔值、整数、浮点数、Null、时间、日期
日期与时间必须使用ISO 8601格式,时间和日期之间使用T连接,最后使用+代表时区,即2018-02-17T15:02:31+08:00
Reference:https://www.runoob.com/w3cnote/yaml-intro.html
2、python:yaml库的使用
f = open("source.yaml","r",encoding="utf-8")
conf_str = f.read()
yaml.load(conf_str, Loader=yaml.FullLoader) # 读取.yaml文件后得到的是字符串,使用这两个函数之一进行yaml化
yaml.safe_load(conf_str)
f.close()
Reference:python 之yaml库使用总结_python yaml库-优快云博客
2万+

被折叠的 条评论
为什么被折叠?



