문제

Has anyone ever found an error like this?

File "C:\Python27\lib\site-packages\yaml\parser.py", line 439, in parse_block_mapping_key
"expected <block end>, but found %r" % token.id, token.start_mark)

ParserError: while parsing a block mapping
  in "a.yml", line 1, column 1
expected <block end>, but found '<block mapping start>'
  in "a.yml", line 224, column 2 

I found it when I tried to load a YAML file using PyYaml. I googled it, but I didn't found anything.

도움이 되었습니까?

해결책

The problem is, I didn't get a valid YAML file. At first, I thought my code was wrong, but, after I checked the Online YAML Parser it returned the same output. Assuming that website is right, the YAML file is not valid.

다른 팁

I had this same error, but for me it was an indentation issue(!)

Line number in error can be misleading. Look at the entire section (indentation) that most likely starts on reported line number.

In my case it was a typo in file. I had:

key5: sub1: 234 sub2: 9879 sub3: "string in quotes"asdf sub4: "another string in quotes"

The parser obviously didnt like asdf outside quotes for sub3 value however line number and column in error pointed to the first entry in indentation (sub1) instead sub3 where the error actually was.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top