鉴于此
输入数据x
是:
{'comm_name': 'XXX', 'comm_value': '1234:5678', 'dev_name': 'router-1'}
marshmallow
模式如下:
让我们加载它及其数据:
schema = BGPcommunitiesPostgresqlSchema()
zzz = schema.load(x)
如果打印出来,我们得到:
zzz.data
Out[17]: {'comm_name': u'XXX', 'comm_value': u'1234:5678'}
目标:我希望最终结果是:
In [20]: zzz.data
Out[20]: (u'XXX', u'1234:5678')
当我做zzz.data
而不是得到dict时,如何实现这个结果(tuple)?在
根据the docs,您可以定义一个
@post_load
修饰函数来在加载模式后返回一个对象。在相关问题 更多 >
编程相关推荐