Python无法从有效的yam解析对象列表

2024-04-25 22:11:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我有yaml配置:

base: /tmp
tasks: 
  - 
    drop: true
    dump_src: "some string here"
    dump_ts: "some string here"
    region: ME
  - 
    dump_src: "some string here"
    dump_ts: "some string here"
    region: RU

它通过了http://yaml-online-parser.appspot.com/http://www.yamllint.com/验证

但当我尝试时:

import yaml

if __name__ == "__main__":
    stream = open(sys.argv[0], 'r')
    docs = yaml.load_all(stream)
    for doc in docs:
        print doc

我有个错误:

yaml.scanner.ScannerError: mapping values are not allowed here
  in "/opt/projects/nextgis/gazetteer-update/gup-web.py", line 7, column 40

Tags: insrccomhttpyamldocsbasestream