我有一个这样的结构,我想使用ruamel.yaml以下命令添加注释行:
xyz:
a: 1 # comment 1
b: 2
test1:
test2:
test3: 3
Run Code Online (Sandbox Code Playgroud)
现在,我想插入注释行(而不是eol_comments)使它看起来像这样:
xyz:
a: 1 # comment 1
b: 2
# before test1 (top level)
test1:
# before test2
test2:
# after test2
test3: 3
Run Code Online (Sandbox Code Playgroud)
我知道,我可以使用添加eol_comments ruamel.yaml,但我没有找到添加整个注释行的方法.