mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-09 00:06:47 +02:00
[yaml/zh-cn]Update yaml-cn.html.markdown
This commit is contained in:
@@ -23,12 +23,12 @@ YAML 根本不容许文字制表符。
|
|||||||
################
|
################
|
||||||
|
|
||||||
# 我们的根对象 (它们在整个文件里延续) 将会是一个映射,
|
# 我们的根对象 (它们在整个文件里延续) 将会是一个映射,
|
||||||
# 它等价于在别的语言里的一个字典,哈西表或对象。
|
# 它等价于在别的语言里的一个字典,哈希表或对象。
|
||||||
key: value
|
key: value
|
||||||
another_key: Another value goes here.
|
another_key: Another value goes here.
|
||||||
a_number_value: 100
|
a_number_value: 100
|
||||||
# 如果你想将数字 1 作为值,你必须要将它括在引号中。
|
# 数字 1 会被解释为数值,而不是一个布尔值。
|
||||||
# 不然 YAML 解析器会假定它是一个布尔值 true。
|
# 如果你想要的是一个布尔值,使用 true。
|
||||||
scientific_notation: 1e+12
|
scientific_notation: 1e+12
|
||||||
boolean: true
|
boolean: true
|
||||||
null_value: null
|
null_value: null
|
||||||
@@ -60,17 +60,17 @@ folded_style: >
|
|||||||
# 集合类型 #
|
# 集合类型 #
|
||||||
####################
|
####################
|
||||||
|
|
||||||
# 嵌套是通过缩进完成的。
|
# 嵌套是通过缩进完成的。推荐使用 2 个空格的缩进(但非必须)
|
||||||
a_nested_map:
|
a_nested_map:
|
||||||
key: value
|
key: value
|
||||||
another_key: Another Value
|
another_key: Another Value
|
||||||
another_nested_map:
|
another_nested_map:
|
||||||
hello: hello
|
hello: hello
|
||||||
|
|
||||||
# 映射的键值不必是字符串。
|
# 映射的键不必是字符串。
|
||||||
0.25: a float key
|
0.25: a float key
|
||||||
|
|
||||||
# 键值也可以是复合型的,比如多行对象
|
# 键也可以是复合型的,比如多行对象
|
||||||
# 我们用 ? 后跟一个空格来表示一个复合键的开始。
|
# 我们用 ? 后跟一个空格来表示一个复合键的开始。
|
||||||
? |
|
? |
|
||||||
This is a key
|
This is a key
|
||||||
@@ -99,6 +99,7 @@ a_sequence:
|
|||||||
# 因为 YAML 是 JSON 的超集,你也可以写 JSON 风格的映射和序列:
|
# 因为 YAML 是 JSON 的超集,你也可以写 JSON 风格的映射和序列:
|
||||||
json_map: {"key": "value"}
|
json_map: {"key": "value"}
|
||||||
json_seq: [3, 2, 1, "takeoff"]
|
json_seq: [3, 2, 1, "takeoff"]
|
||||||
|
and quotes are optional: {key: [3, 2, 1, takeoff]}
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# 其余的 YAML 特性 #
|
# 其余的 YAML 特性 #
|
||||||
@@ -113,6 +114,9 @@ other_anchor: *anchor_name
|
|||||||
base: &base
|
base: &base
|
||||||
name: Everyone has same name
|
name: Everyone has same name
|
||||||
|
|
||||||
|
# The regexp << is called Merge Key Language-Independent Type.
|
||||||
|
# 它表明指定映射的所有键值会插入到当前的映射中。
|
||||||
|
|
||||||
foo: &foo
|
foo: &foo
|
||||||
<<: *base
|
<<: *base
|
||||||
age: 10
|
age: 10
|
||||||
@@ -157,7 +161,7 @@ set:
|
|||||||
? item2
|
? item2
|
||||||
? item3
|
? item3
|
||||||
|
|
||||||
# 像 Python 一样,集合仅是值为 null 的映射;上面的集合等价于:
|
# 集合只是值为 null 的映射;上面的集合等价于:
|
||||||
set2:
|
set2:
|
||||||
item1: null
|
item1: null
|
||||||
item2: null
|
item2: null
|
||||||
|
Reference in New Issue
Block a user