python yaml文件读写

 

import yaml
yaml_dict={"sss":"111","ddd":"222"}
with open("a.yaml", "w") as f:
    yaml.safe_dump(yaml_dict,f,encoding='utf-8', allow_unicode=True)

with open("a.yaml") as f:
    yaml_dict = yaml.load(f)
    print(yaml_dict)

 

posted @ 2018-11-23 19:00  anobscureretreat  阅读(379)  评论(0编辑  收藏  举报