相关疑难解决方法(0)

如何实现Python的内置词典

有谁知道如何实现python的内置字典类型?我的理解是它是某种哈希表,但我无法找到任何确定的答案.

python dictionary data-structures

263
推荐指数
3
解决办法
7万
查看次数

作为 YAML 数组的编号列表

代替

key:
    - thisvalue
    - thatvalue
    - anothervalue
Run Code Online (Sandbox Code Playgroud)

我想拥有

key:
    1. thisvalue
    2. thatvalue
    3. anothervalue
Run Code Online (Sandbox Code Playgroud)

纯粹为了人类可读性,具有相同的解释{key: [thisvalue, thatvalue, anothervalue]}

这似乎不是基本 YAML 语法的一部分,但是有没有办法实现这一点 - 也许使用YAML 中可能的一些高级技巧?

(我意识到这可以通过将列表写为以下形式来近似:

key:
    - 1. thisvalue
    - 2. thatvalue
    - 3. anothervalue
Run Code Online (Sandbox Code Playgroud)

但这是一个丑陋的黑客,我更喜欢一种解决方案,其中数字具有语义目的,而不仅仅是值文本的一部分,这也需要被解析和删除。)

syntax grammar yaml numbered-list

5
推荐指数
1
解决办法
9372
查看次数