yaml学习

yaml文件:

name: junxi
age: 18
spouse:
    name: Rui
    age: 18
children:
    - name: Chen You
      age: 3
    - name: Ruo Xi
      age: 2

python测试:

import yaml
with open(filename) as f:
    content = yaml.load(f)
print( type(content))
print( '修改前: ', content)
content['age'] = 17
content['children'][1]['age'] = 1
print('修改后: ', content)

YAML 语法:

http://ansible-tran.readthedocs.io/en/latest/docs/YAMLSyntax.html

你可能感兴趣的:(Python)