YAML introduction
1# @Time : 2019-02-02 2# @Language: Markdown 3# @Software: VS Code 4# @Author : Di Wang 5# @Email : [email protected] A Short Report on YAML YAML means “YAML Ain’t a Markup Language”. It uses Python-style indentation to indicate nesting, and use [] for lists and {} for maps. Since the name is recursive, it is a better option to explain YAML by YAML. 1--- # Syntax 2basic syntax: 3 - whitespace indentation is used for denoteing structure and `tab` is not allowed 4 - comments begin with the `#` 5 - List members are denoted by leading hyphen (`-`) with one member per line 6 - use key:value to denote array 7 - case sensitive 8Support data structure: 9 - map (also called dictionary or hashes or key:value pair) 10 - array or list or sequence 11 - scalars 12 13# basic components 14map: 15 - map1: this is a map 16 - map2: {name: hello, id: world} 17list: 18 - cat 19 - dog 20 - cow 21 - [monkey, elephant] 22scalars: 23 null: ~ 24 boolean: 25 - TRUE # True (yaml1.1), string "Yes" (yaml1.2) 26 - FALSE 27 - yes 28 - no 29 - Yes 30 - YeS # will be recognized as a string 31 float: 32 - 3.14 33 - 2.99e+8 34 int: 35 - 65536 36 - 0b1010 # dec: 10 37 srting: 38 - apple 39 - "another string" 40 - '\n will be escaped' 41 - "\n will not be escaped" 42 - data: | 43 There once was a tall man from Ealing 44 Who got on a bus to Darjeeling 45 It said on the door 46 "Please don't sit on the floor" 47 So he carefully sat on the ceiling 48 - info: > 49 this is 50 an 51 info 52 53 \n 54 continued 55 info 56date and time: 57 # {date}t{time}+timezone 58 - iso8601: 2001-12-25t01:23:45.54+09:00 59 - date: &epoch 1970-01-01 60 - epochtime: *epoch 61explicit type: 62 str_true: !!str true # string rather than boolean 63 str_int: !!str 123 # string rather than int 64anchor and refers: 65 - anchor: &anchor001 66 Manager: Alice 67 Programer: Bob 68 Teacher: Dylan 69 Student: Ruby 70 - refer: *anchor001 71 - merger: 72 <<: *anchor001 73 Student: Python Parse this YAML file by Python3. ...