0
我試圖解析以下YAML文件:在YAML文件文檔字符串定義:解析錯誤
\- api:
api_first: """this is some docstring """
我基本上要使用三引號,並具有在其中一些語句。 但是當我使用的YAML庫,它拋出一些錯誤,我
In [1]: import yaml
In [2]:with open('new.yaml') as f:
...: dataMap = yaml.safe_load(f)
---------------------------------------------------------------------------
ParserError Traceback (most recent call last)
<ipython-input-2-2266b3e8606a> in <module>()
1
2 with open('new.yaml') as f:
----> 3 dataMap = yaml.safe_load(f)
/phaedrus/home/skorada/lib/python3.5/site-
packages/yaml/parser.py in parse_block_sequence_entry(self)
391 token = self.peek_token()
392 raise ParserError("while parsing a block collection",
self.marks[-1],
--> 393 "expected <block end>, but found %r" % token.id,
token.start_mark)
394 token = self.get_token()
395 event = SequenceEndEvent(token.start_mark, token.end_mark)
ParserError: while parsing a block collection
in "new.yaml", line 1, column 1
expected <block end>, but found '?'
in "new.yaml", line 2, column 1
真的不知道是什麼問題?
嗨Anthon,謝謝你的回覆。我想我正在嘗試多線。這可以通過使用「|」來解決它爲我工作。 – skorada
這是我在答案中指出的「塊樣式字面標量」。我應該包括一個例子。 – Anthon