问题描述
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)
运行结果:
运行结果正确.