
[英]PyYAML error: Could not determine a constructor for the tag '!vault'
[英]PyYAML throwing unsolvable error
我正在使用YAML文件,并且只能使用“ |” 用于文字引号。
我正在使用PyYAML。
此处的主要问题是,它适用于以下代码中的第一级“字典”键,但不适用于第二级“注释”键。
我尝试使用“>”“ | +”“ |-”,但是没有任何效果。
Description: |
This is a sample text showing that it works fine here.
Signatures:
- {
returnValue: 'placeholder',
notes: |
Its not working here
}
- {
returnValue: 'another placeholder',
notes: '
This is working here
'
}
我检查了语法上http://yaml-online-parser.appspot.com/ , https://nodeca.github.io/js-yaml/并加上其他的,我得到了错误
错误:扫描下一个令牌时发现字符“ |” 不能在“”第8行第24列的第一个令牌中启动任何标记:
我遍历了线程在YAML中,如何在多行中中断一个字符串? 和其他几个,但没有任何效果。
首先,请始终制作引发错误的最小示例:
{ notes: |
Its not working here
}
如果您查看YAML规范并搜索字符串“ literal style”,则您的第一个匹配项是“表”中的“表8.2.1”部分,该部分是“ 块样式 ”描述的一部分
您的代码使用{ }
指定映射的流样式,在其中不能有块样式的文字标量。
您应该只使整个YAML一致地使用块样式(删除映射元素之间的{}
和,
):
Description: |
This is a sample text showing that it works fine here.
Signatures:
- returnValue: placeholder
notes: |
Its not working here
- returnValue: another placeholder
notes: '
This is working here
'
顺便说一句,因为文字标量的默认斩波是裁剪的 ,所以如果在标量的末尾添加多余的空行,它不会改变任何内容。
(PyYAML仅支持YAML 1.1,但此规范未更改)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.