【发布时间】:2016-02-29 02:36:08
【问题描述】:
我有一个空的 YAML 文件,当我加载它时,我想将它作为一个空字典加载。例如,我有
import yaml
with open('an_empty_file.yml', 'r') as config_file:
config=yaml.load(config_file)
print(config)
None
事实证明yaml.load(config_file) 将返回一个NoneType 对象,我认为这是有道理的。有没有简单的方法来返回一个空字典?
【问题讨论】:
标签: python dictionary yaml