2024-06-01 08:29:09 发布
网友
我有python字典和架构.yaml. 有没有一种方法来验证这两种方法?如果我把字典作为数据.yaml,我可以使用下面的代码进行验证。 有没有办法用字典验证模式文件?在
from pykwalify.core import Core c = Core(source_file="data.yaml", schema_files=["schema.yaml"]) c.validate(raise_exception=True)
我自己也找到了答案。从pyKwalify类的源Core类接受source_data,如果没有指定source_file。
Core
source_data
source_file
class Core(object): """ Core class of pyKwalify """ def __init__(self, source_file=None, schema_files=[], source_data=None, schema_data=None, extensions=[]): ... ... if self.source is None: log.debug(u"No source file loaded, trying source data variable") self.source = source_data
所以我可以用做-
我自己也找到了答案。从pyKwalify类的源
Core
类接受source_data
,如果没有指定source_file
。所以我可以用做-
^{pr2}$相关问题 更多 >
编程相关推荐