Basic use of python yaml

1. Hope that the output is all in a dictionary format:

{
  "get": {
    "method": "post",
    "url": "https://qyapi.weixin.qq.com/cgi-bin/tag/get",
    "params": {
      "access_token": "${token}",
      "tagid": 3
    },
    "json": null
  }
}

It should be written in the yaml file as:

get:
  method: post
  url: https://qyapi.weixin.qq.com/cgi-bin/tag/get
  params:
    access_token: ${token}
    tagid: 3
  json:

2. If you want tagid to be a list, as follows:

{
  "tagid": [
    {
      "name": "${id}",
      "class": "${class}"
    }
  ]
}

The wording of the yaml file:

tagid:
  - name: ${id}
    class: ${class}

The ${class} indicates that this is a placeholder for a variable

3. If you want 3 in tagid to be a string:

 "tagid": "3"

It can be written as a yaml file:

tagid: "3"

 

Guess you like

Origin blog.csdn.net/chuancheng_zeng/article/details/109254421