【问题标题】:Difference between Array and Dictionary in YAMLYAML中数组和字典的区别
【发布时间】:2021-04-11 03:56:32
【问题描述】:

我理解数组和字典之间的区别,比如在 python 中——尤其是在访问两者中的内容时。

但是在 YAML 中,我发现很难区分两者,尤其是在编写结构时。请问它们的定义有何不同?

【问题讨论】:

    标签: yaml


    【解决方案1】:

    @kebanus ...这是我正在查看的示例

    ...在我看来,一切都像是一本普通的字典...但作者称它们为数组_,除了第一个基本的键值对:

    doe: "a deer, a female deer"
     ray: "a drop of golden sun"
     pi: 3.14159
     xmas: true
     french-hens: 3
     calling-birds:
       - huey
       - dewey
       - louie
       - fred
     xmas-fifth-day:
       calling-birds: four
       french-hens: 3
       golden-rings: 5
       partridges:
         count: 1
         location: "a pear tree"
       turtle-doves: two
    

    【讨论】:

    • 如果您想提供更多详细信息,请编辑您的问题。这不是一个答案。这甚至不是有效的 YAML,doe 不能同时具有标量和映射值。
    猜你喜欢
    • 2017-04-03
    • 2012-03-14
    • 1970-01-01
    • 2021-02-10
    • 1970-01-01
    • 2016-03-22
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多