读取ymal时报错解决YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loa

一、解决报错问题

YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsa

二、解决办法

三、运行后解决报错

四、原因:

YAML 5.1版本后弃用了yaml.load(file)这个用法,因为觉得很不安全,5.1版本之后就修改了需要指定Loader,通过默认加载​​器(FullLoader)禁止执行任意函数,该load函数也变得更加安全

示例代码:

    import yaml
     
    file = open('familyinfo.yaml','r')
    data = yaml.load(file,Loader=yaml.FullLoader)
     
    print(data)

转发:https://blog.csdn.net/dengachao/article/details/100523977

posted @ 2021-06-08 16:22  zntest  阅读(321)  评论(0编辑  收藏  举报