<legend id='hWZwD'><style id='hWZwD'><dir id='hWZwD'><q id='hWZwD'></q></dir></style></legend>
          <bdo id='hWZwD'></bdo><ul id='hWZwD'></ul>
      1. <tfoot id='hWZwD'></tfoot>
      2. <small id='hWZwD'></small><noframes id='hWZwD'>

        <i id='hWZwD'><tr id='hWZwD'><dt id='hWZwD'><q id='hWZwD'><span id='hWZwD'><b id='hWZwD'><form id='hWZwD'><ins id='hWZwD'></ins><ul id='hWZwD'></ul><sub id='hWZwD'></sub></form><legend id='hWZwD'></legend><bdo id='hWZwD'><pre id='hWZwD'><center id='hWZwD'></center></pre></bdo></b><th id='hWZwD'></th></span></q></dt></tr></i><div id='hWZwD'><tfoot id='hWZwD'></tfoot><dl id='hWZwD'><fieldset id='hWZwD'></fieldset></dl></div>

        'yaml.parser.ParserError: expected '&lt;document

        时间:2023-09-13
          <bdo id='snH9M'></bdo><ul id='snH9M'></ul>
            <i id='snH9M'><tr id='snH9M'><dt id='snH9M'><q id='snH9M'><span id='snH9M'><b id='snH9M'><form id='snH9M'><ins id='snH9M'></ins><ul id='snH9M'></ul><sub id='snH9M'></sub></form><legend id='snH9M'></legend><bdo id='snH9M'><pre id='snH9M'><center id='snH9M'></center></pre></bdo></b><th id='snH9M'></th></span></q></dt></tr></i><div id='snH9M'><tfoot id='snH9M'></tfoot><dl id='snH9M'><fieldset id='snH9M'></fieldset></dl></div>

              • <legend id='snH9M'><style id='snH9M'><dir id='snH9M'><q id='snH9M'></q></dir></style></legend>

                  <tbody id='snH9M'></tbody>

                <tfoot id='snH9M'></tfoot>

                  <small id='snH9M'></small><noframes id='snH9M'>

                • 本文介绍了'yaml.parser.ParserError: expected '&lt;document start&gt;', but found '&lt;block mapping start&gt;'' 是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有以下 YAML 文件:

                  I have the following YAML file:

                  [mysqld]
                  user: "mysql"
                  pid-file: /var/run/mysqld/mysqld.pid
                  skip-external-locking
                  old_passwords: 1
                  skip-bdb
                  skip-innodb
                  create_key: yes
                  needs_agent: no
                  knows_oop: True
                  likes_emacs: TRUE
                  women:
                      - Mary Smith
                      - Susan Williams
                  

                  以及以下 Python 代码:

                  and the following Python code:

                  #!/usr/bin/env python
                  
                  import yaml
                  
                  
                  with open("config.yml") as f:
                      sample_config = f.read()
                  
                  print(yaml.load(sample_config))
                  

                  但它给了我:

                  Traceback (most recent call last):
                    File "/home/moose/Desktop/bla.py", line 9, in <module>
                      print(yaml.load(sample_config))
                    File "/usr/local/lib/python2.7/dist-packages/yaml/__init__.py", line 71, in load
                      return loader.get_single_data()
                    File "/usr/local/lib/python2.7/dist-packages/yaml/constructor.py", line 37, in get_single_data
                      node = self.get_single_node()
                    File "/usr/local/lib/python2.7/dist-packages/yaml/composer.py", line 39, in get_single_node
                      if not self.check_event(StreamEndEvent):
                    File "/usr/local/lib/python2.7/dist-packages/yaml/parser.py", line 98, in check_event
                  [Finished in 0.1s with exit code 1]
                  [shell_cmd: python -u "/home/moose/Desktop/bla.py"]
                  [dir: /home/moose/Desktop]
                  [path: /usr/local/texlive/2013/bin/x86_64-linux:/home/moose/google-cloud-sdk/bin:/home/moose/Downloads/google_appengine:/usr/local/texlive/2013/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games]    self.current_event = self.state()
                    File "/usr/local/lib/python2.7/dist-packages/yaml/parser.py", line 174, in parse_document_start
                      self.peek_token().start_mark)
                  yaml.parser.ParserError: expected '<document start>', but found '<block mapping start>'
                    in "<string>", line 2, column 1:
                      user: "mysql"
                  

                  我不知道是什么

                  expected '<document start>', but found '<block mapping start>'
                  

                  意味着以及如何解决它.什么是<document start>,什么是<block mapping start>?

                  means and how to fix it. What is <document start> and what is a <block mapping start>?

                  推荐答案

                  您的文件不是有效的 YAML.它看起来像是 YAML 和 INI 文件 的混合体.

                  Your file isn't valid YAML. It looks like a mix of YAML and INI file.

                  • 你不能在 YAML 中定义像 [mysql] 这样的块.如果要定义相关属性的集合,请使用带有嵌套键的列表:

                  • You can't define blocks like [mysql] in YAML. If you want to define a collection of related properties, use a list with nested keys:

                  - service:
                      name: mysql
                      type: database
                      port: 3306
                  - service:
                      name: ssh
                      type: remote access
                      port: 22
                  

                • 您不能使用 skip-external-locking 之类的裸词.每个属性都需要一个值.请改用 skip-external-locking: true.

                • You can't have bare words like skip-external-locking. Each property requires a value. Use skip-external-locking: true instead.

                  这是您的文档的一个版本,其中修正了语法错误.我使用 YAMLLint 进行了检查,这是一个用于验证 YAML 的便捷工具.

                  Here's a version of your document with the syntax errors fixed. I checked this over with YAMLLint, a handy tool for validating YAML.

                  name: mysqld
                  user: mysql
                  pid-file: /var/run/mysqld/mysqld.pid
                  skip-external-locking: true
                  old_passwords: 1
                  skip-bdb: true
                  skip-innodb: true
                  create_key: yes
                  needs_agent: no
                  knows_oop: True
                  likes_emacs: TRUE
                  women:
                      - Mary Smith
                      - Susan Williams
                  

                  这篇关于'yaml.parser.ParserError: expected '&lt;document start&gt;', but found '&lt;block mapping start&gt;'' 是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                • 上一篇:Loaddata 未正确处理时间戳和时区 下一篇:YAML:转储不带引号的 Python 列表

                  相关文章

                  最新文章

                  <i id='BcAMK'><tr id='BcAMK'><dt id='BcAMK'><q id='BcAMK'><span id='BcAMK'><b id='BcAMK'><form id='BcAMK'><ins id='BcAMK'></ins><ul id='BcAMK'></ul><sub id='BcAMK'></sub></form><legend id='BcAMK'></legend><bdo id='BcAMK'><pre id='BcAMK'><center id='BcAMK'></center></pre></bdo></b><th id='BcAMK'></th></span></q></dt></tr></i><div id='BcAMK'><tfoot id='BcAMK'></tfoot><dl id='BcAMK'><fieldset id='BcAMK'></fieldset></dl></div>
                  1. <legend id='BcAMK'><style id='BcAMK'><dir id='BcAMK'><q id='BcAMK'></q></dir></style></legend><tfoot id='BcAMK'></tfoot>
                      <bdo id='BcAMK'></bdo><ul id='BcAMK'></ul>

                      <small id='BcAMK'></small><noframes id='BcAMK'>