我想从我使用加载的 YAML 文件中获取注释字符串ruamel.yaml
。项目文档缺少 API 参考,我找不到相关示例。访问评论的正确方法是什么?
import ruamel.yaml
yaml = """\
%YAML 1.2
---
# C1
a: # C2
# C3
# C4
b: 1 # C5
c: # A comment here will not be parsed properly by ruamel.yaml v0.11.14
- abc # C6
- xyz # C7
# C8
# C9
"""
loaded = ruamel.yaml.round_trip_load(yaml)
# Now what?