Python3.x need to install version PyYAML]

Referenced blog: https://blog.csdn.net/vincent_hbl/article/details/75411243

Doing the automation interface testing, beginning are using the json to store profile information, but can not comment json data format, code readability is not high, so the use of YAML to store. YAML is a simple non-markup language. YAML data-centric, use a blank, indentation, branches organize data so that represents more concise and easy to read.

basic rules

YAML has the following basic rules: 
1, case sensitive 
2, using the hierarchical relationship indention 
3, prohibit the use of tab indentation, only using the space bar 
4, indent length is not limited as long as the elements are aligned on one level represents the element belonging to . 
5, using the # indicates a comment 
6, the string can not quotation marks

Three data structures

1, map, hash tables 
use a colon (:) indicates the key to all keys belonging to the same indent a map, example:

A map can also be written on one line:

2, list, array 
using a hyphen (-), said:

It can also be written in one line:

3, scalar, scalar 
smallest unit of data, can not be subdivided.

Nested data structure

The elements of the map and list may be another map or list or scalar. Whereby the four common data appears nested: 
. 1, nested map map

2, map nested list

3, list nested list

In addition, this configuration can also be represented as follows

4, list nested map

 

Guess you like

Origin www.cnblogs.com/shixue/p/11022348.html