ScannerError:Python此处不允许使用映射值

时间:2020-05-12 14:10:16

标签: python yaml

我在打开应用于小组项目的yaml文件时遇到一些问题。

给出错误的代码非常简单;

import yaml
with open('test2.yaml') as f:    
    data = yaml.load(f, Loader=yaml.FullLoader)
    print(data)

错误消息是;

ScannerError: mapping values are not allowed here
  in "test2.yaml", line 118, column 73

我调查了这个问题,它应该是yaml文件格式的问题。但是,我尝试使用不同的Yaml文件进行了此操作,但它们均无效。我还尝试了在线yaml文件验证器,这些文件似乎还不错。我真的不明白这里出了什么问题,将不胜感激。

顺便说一下,yaml文件的示例也如下所示:

description:
  set: 'Container'
  name: 'Test'
layout:
  containers:
  - id: 1
    kindid: 1
    loadingspaces:
    - id: 1
      placements:
      - id: 1
        itemid: 1
        position: 0,0,0
        orientation: 'LWH'
      - id: 2
        itemid: 1
        position: 0,0,500
        orientation: 'LWH'
      - id: 3
        itemid: 1
        position: 0,500,0
        orientation: 'LWH'
  pallets: []
  boxes: []
  unplaced:
  - id: 4
    itemid: 1
    quantity: 1

0 个答案:

没有答案