【发布时间】:2017-06-22 15:38:03
【问题描述】:
ruamel.yaml.RoundTripRepresenter.add_representer(type(None), represent)
在0.14.X 版本的 ruamel.yaml 包中运行良好
如何在 ruamel.yaml 包的旧版本 ( ) 中使用相同的功能或在以前版本的包中使用的替代方式?
这是我的程序示例
def represent(self, data):
return self.represent_scalar(u'tag:yaml.org,2002:null', u'NULL')
ruamel.yaml.RoundTripRepresenter.add_representer(type(None), represent)
data = ruamel.yaml.round_trip_load(input.yaml)
ruamel.yaml.round_trip_dump(data, output.yaml)
在运行上面的代码时遇到错误
ruamel.yaml.RoundTripRepresenter.add_representer(type(None), represent_none)\nAttributeError: 'module' object has no attribute 'RoundTripRepresenter'
【问题讨论】:
-
为什么要使用 ruamel.yaml
-
ruamel.yaml(版本:0.10.11)是我们自定义 ISO 中的默认包,
-
是否有机会获得有关该自定义 ISO 的更多信息(可能通过电子邮件)?只是出于对我的包裹的使用方式/位置感兴趣。
标签: yaml pyyaml ruamel.yaml