linux python2.7 编写程序读取yaml文件中的内容时,报yaml.constructor.ConstructorError:while constructing a mapping
程序内:
with open(yaml_file, 'r') as f: cfg = yaml.safe_load(f) print cfg
执行时报:yaml.constructor.ConstructorError:while constructing a mapping
试试:cfg = yaml.safe_load(f.read())
with open(yaml_file, 'r') as f:
cfg = yaml.safe_load(f.read())
print cfg