所以我有一个包含很多琐事问题和答案列表的 yaml 文件。但是,每当我尝试加载此文件并使用 pyyaml 转储 python 中的内容时,它会将它们向后转储。我不确定这是我的 yaml 文件还是我对库做错了什么。
假设我的一个问题/答案对在 yaml 文件中看起来像这样 -
{"question": "What is the name of this sequence of numbers: 1, 1, 2, 3, 5, 8, 13, ...",
"answer": ["The Fibonacci Sequence", "The Padovan Sequence", "The Morris Sequence"]}
当我在那个 python 字典上使用 yaml.dump() 时,它会转储这个 -
answer: [fibonacci, padovan, morris]\nquestion: 'what sequence is this: 1, 1, 2, 3, 5, 8, 13, ...'\n"
我期待这个 -
- question: "What is the name of this sequence of numbers: 1, 1, 2, 3, 5, 8, 13, ..."
answer: ["The Fibonacci Sequence", "The Padovan Sequence", "The Morris Sequence"]
我在这里做错了吗?