with open(r'E:\file\file.json', 'r') as data_compare:
d1 = json.load(data_compare)
set1 = set(d1)
with open(r'E:\file\file2.json', 'r') as data_updated:
d2 = json.load(data_updated)
set2 = set(d2)
compare = set2 - set1
print(compare)
出于某种原因,此输出仅是“ set()”,任何人都可以解释我在做什么错吗?这是我的一个json文件的小样本(另一个在结构和键方面相同,只是值不同)
{
"data": [
{
"Process": "proc",
"num": "00000",
},
{
"Process": "process",
"num": "00101",
}
]
}
这不是重复的,这涉及将数据从json加载到python对象,而不是比较现有的python字典