所以我有一个yaml文件,有很多琐事问题和答案列表。然而,每当我尝试加载这个文件并用pyyaml转储python中的内容时,它会将它们倒转回去。我不确定是否是我的yaml文件,或者我是否在图书馆做错了什么。PyYaml倾倒东西
比方说,我的问题/答案对一个看起来像这样在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"]
难道我做错了什么吗?
谢谢,所以我做错了什么,我只是不知道它是什么。 – 2012-03-31 00:42:54