Basic YAML syntax
Http://ansible-tran.readthedocs.io/en/latest/docs/YAMLSyntax.html
YAML also has a small quirk. All YAML files (regardless of whether they have a relationship with Ansible) should be started ---
. This is part of the YAML format, which indicates the beginning of a file.
All members in the list start at the same indentation level and use one "- "
as the beginning (a bar and a space):
---# A list of delicious fruit notes using #AppleOrangeStrawberryMango
A dictionary is made 键: 值
up of a simple form (the colon must be followed by a space):
---# One employee's record name:example Developerjob:Developerskill:Elite
Python operations
Import Yaml """ pip Install pyyamlhttp://ansible-tran.readthedocs.io/en/latest/docs/yamlsyntax.html """ = open ('a.yaml', encoding='utf-8'= yaml.load (f) Print (RES)
F.close ()
Example
---# A list of delicious fruit notes using #- Apple- Orange- Strawberry- Mango Returns the result [ ' Apple ' ' Orange ' ' Strawberry ' ' Mango ']
---# A worker's record name:example developerjob:developerskill:elitekey,value form Dictionary Returns the result {' name'Example Developer'job' ' Developer ' ' Skill ' ' Elite '}
-URL:/api/user/Login method:post Detail: normal login Data:username:niuhanyang passwd:aa123456 check:-userId- Sign-URL:/api/user/Login Method:post Detail: Do not pass the password Data:username:niuhanyang check:-Required parameter not filled return result: [{'URL':'/api/user/login','Method':'Post','Detail':'Normal Login','Data': {'username':'Niuhanyang','passwd':'aA123456'},'Check': ['userId',' Sign']},
{'URL':'/api/user/login','Method':'Post','Detail':'do not pass the password','Data': {'username':'Niuhanyang'},'Check': ['Required parameters not filled']}]
Python manipulating Yaml files