总结:
1.前提条件dict1和dict2 相同,将dict2中key1对应value(类型为列表)删除某个元素,cmp_dict=deepdiff.DeepDiff(dict1,dict2,ignore_order=True).to_dict(),返回值cmp_dict字典中不会存在key为"dictionary_item_removed"的元素
import configparser
import os
import sys
import json
import deepdiff
base_path=os.getcwd()
sys.path.append(base_path)
class HandleResult:
def __init__(self):
pass
def handle_result_json(self,dict1,dict2):
# dict1={"aaa":"AAA","bbb":"BBBB","CC":[{"11":"22"},{"33":"44"}]}
# dict2={"aaa":"AAAA","bbb":"BBBB1","CC":[{"11":"222"},{"33":"44"}]}
# dict3={"bbb":"BBBB","CC":[{"11":"22"},{"33":"44"}],"EE":"eee"}
#print(deepdiff.DeepDiff(dict3,dict2,ignore_order=True).to_dict())
cmp_dict=deepdiff.DeepDiff(dict1,dict2,ignore_order=True).to_dict()
print(cmp_dict)
if cmp_dict.get("dictionary_item_added") or
cmp_dict.get("dictionary_item_removed"):
print("case执行失败")
return False
else:
print("case执行成功")
return True
pass
def get_result_json(self,url):
data= handJson.get_valu