YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated

问题描述

YAMLLoadWarning: calling yaml.load() without Loader=… is deprecated

问题分析

这是yaml加载时出错,此时要更换加载语句

解决方案

之前的代码:

__author__='yym'
import sys
import yaml
f = open('yaml_set.yaml')
content = yaml.load(f)
print(type(content))
print("修改前:", content)
content['mqtt']['num'] = 80
print("修改后:", content)

修改之后的代码:

__author__='yym'
import sys
import yaml
f = open('yaml_set.yaml')
content = yaml.load(f, Loader=yaml.FullLoader)
print(type(content))
print("修改前:", content)
content['mqtt']['num'] = 80
print("修改后:", content)

运行结果:
在这里插入图片描述
运行结果正确.

©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页