你怎么在YAML表达这个?

时间:2016-04-23 02:48:48

标签: yaml

[2, "single", {"avoidEscape": true, "allowTemplateLiterals": true}]

2 个答案:

答案 0 :(得分:2)

这已经是正确的YAML。但如果你想要可以取消不必要的双引号:

import sys
import ruamel.yaml

yaml_str = """\
[2, "single", {"avoidEscape": true, "allowTemplateLiterals": true}]
"""

data = ruamel.yaml.round_trip_load(yaml_str)
ruamel.yaml.round_trip_dump(data, sys.stdout)

给出:

[2, single, {avoidEscape: true, allowTemplateLiterals: true}]

答案 1 :(得分:1)

- 2
- single
- allowTemplateLiterals: true
  avoidEscape: true