2
我有python字典和schema.yaml。有沒有一種方法來驗證兩者?如果我將字典轉儲爲yaml文件作爲data.yaml,我可以使用下面的代碼進行驗證。 有沒有辦法用字典驗證模式文件?Pykwalify:根據yaml文件模式驗證字典中的數據
from pykwalify.core import Core
c = Core(source_file="data.yaml", schema_files=["schema.yaml"])
c.validate(raise_exception=True)
你有沒有在你的最後一行代碼的意思'source_data',而不是'source_file'? – dougli1sqrd
Right @ dougli1sqrd。糾正。謝謝。 – Rilwan