(十二)YAML数据转换

YAML数据转换

1.数据转化

方法:dump()可以将Python对象序列化成YAML流,如果stream为None,则返回生成的字符串。

2.测试场景

将下面的Python数据转换成yaml数据类型

slogan=['welcome','to','baidu']

website=[‘url’:'www.baidu.com']

代码实现

 

 打印结果:

 

posted @ 2019-11-01 17:36  xxy会飞的鱼  阅读(874)  评论(0编辑  收藏  举报