python-yaml

配置文件:

# 字典
platformVersion : 7.1
platformName : Android
deviceName :
name : 11
sex : hehe
age : 13
demo:
- hello
- yaml
- yeah
test : ttttt

 

文件获取:

import yaml


fs = open("caps.yaml")
res = yaml.full_load(fs)
print(res)



执行结果:

{'platformVersion': 7.1, 'platformName': 'Android', 'deviceName': {'name': 11, 'sex': 'hehe', 'age': 13}, 'demo': ['hello', 'yaml', 'yeah'], 'test': 'ttttt'}

posted @ 2022-04-05 14:38  狒狒桑  阅读(45)  评论(0)    收藏  举报