【发布时间】:2023-03-22 23:14:01
【问题描述】:
我想要来自ruamel.yaml 的dict(或OrderedDict)。
我正在使用 Python 3.8,如果有帮助,我很乐意切换到 3.9。
from ruamel.yaml import YAML
from collections import OrderedDict
with open(self.filename) as f:
data = yaml.load(f)
print(type(data)) # <class 'ruamel.yaml.comments.CommentedMapItemsView'>
data = dict(yaml.load(f))
print(type(data)) # <class 'dict_items'>
data = yaml.load(f).items() # AttributeError: 'NoneType' object has no attribute 'items'
【问题讨论】:
标签: python python-3.x ruamel.yaml