summaryrefslogtreecommitdiffhomepage
path: root/zh-cn/yaml-cn.html.markdown
blob: 8370b22489a591e9b9aa4dbd32ad5c708f17e65a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
---
language: yaml
contributors:
  - ["Adam Brenecki", "https://github.com/adambrenecki"]
translators:
  - ["Zach Zhang", "https://github.com/checkcheckzz"]
filename: learnyaml-cn.yaml
lang: zh-cn
---

YAML��һ���������л����ԣ�����Ƴ�����ֱ�ӿ�д�ɶ��ġ�

����JSON���ϸ񳬼����������﷨�������з�������������Python������Python��һ����
YAML���������������Ʊ�����


```yaml
# YAML�е�ע�⿴������������

################
# �������� #
################

# ���ǵĸ����� (�����������ļ�������) ������һ����ͼ��
# ���ȼ����ڱ���������һ���ֵ䣬�����������
key: value
another_key: Another value goes here.
a_number_value: 100
scientific_notation: 1e+12
boolean: true
null_value: null
key with spaces: value
# ע�⵽�ַ�������Ҫ�����á����ǣ����ǿ��Ա����á�
"Keys can be quoted too.": "Useful if you want to put a ':' in your key."

# �����ַ����ȿ���д����һ��'���ֿ�'(ʹ�� |)��
# ����һ��'�۵���'(ʹ�� '>')��
literal_block: |
    This entire block of text will be the value of the 'literal_block' key,
    with line breaks being preserved.

    The literal continues until de-dented, and the leading indentation is
    stripped.

        Any lines that are 'more-indented' keep the rest of their indentation -
        these lines will be indented by 4 spaces.
folded_style: >
    This entire block of text will be the value of 'folded_style', but this
    time, all newlines will be replaced with a single space.

    Blank lines, like above, are converted to a newline character.

        'More-indented' lines keep their newlines, too -
        this text will appear over two lines.

####################
# �������� #
####################

# Ƕ����ͨ��������ɵġ�
a_nested_map:
    key: value
    another_key: Another Value
    another_nested_map:
        hello: hello

# ͼ�������ַ�����ֵ��
0.25: a float key

# ��ֵҲ�����Ƕ��ж�����?������ֵ�Ŀ�ʼ��
? |
    This is a key
    that has multiple lines
: and this is its value

# YAMLҲ������ֵ�Ǽ������ͣ����Ǻܶ����Խ��ᱧԹ��

# ���� (�ȼ��ڱ�������) ��������������
a_sequence:
    - Item 1
    - Item 2
    - 0.5 # sequences can contain disparate types
    - Item 4
    - key: value
      another_key: another_value
    -
        - This is a sequence
        - inside another sequence

# ��ΪYAML��JSON�ij�������Ҳ����дJSON���ĵ�ͼ�����У�
json_map: {"key": "value"}
json_seq: [3, 2, 1, "takeoff"]

#######################
# �����YAML�ص� #
#######################

# YAML����һ��������ص��'ê'��������򵥵��������ļ����ظ����ݡ�
# ������ֵ��������ͬ��ֵ��
anchored_content: &anchor_name This string will appear as the value of two keys.
other_anchor: *anchor_name

# YAML���б�ǩ�������������ʾ���������͡�
explicit_string: !!str 0.5
# һЩ������ʵ���ض����Եı�ǩ���������Ϊ��Python�ĸ������͡�
python_complex_number: !!python/complex 1+2j

####################
# �����YAML���� #
####################

# �ַ��������ֲ��ǽ��е�YAML��������ı�����
# ISO ��ʽ�����ں�����ʱ������Ҳ�ǿ��Ա������ġ�
datetime: 2001-12-15T02:59:43.1Z
datetime_with_spaces: 2001-12-14 21:59:43.10 -5
date: 2002-12-14

# ���!!binary��ǩ����һ���ַ���ʵ������һ��������blob��base64�����ʾ��
gif_file: !!binary |
    R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
    OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
    +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
    AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=

# YAML����һ���������ͣ�����������������
set:
    ? item1
    ? item2
    ? item3

# ��Pythonһ�������Ͻ�����null��ֵ�ĵ�ͼ������ļ��ϵȼ��ڣ�
set2:
    item1: null
    item2: null
    item3: null
```