python3 比较两个json文件内容是否一致 输出True False
import hashlib
def getHash(f):
line=f.readline()
hash=hashlib.md5()
while(line):
hash.update(line)
line=f.readline()
return hash.hexdigest()
def IsHashEqual(f1,f2):
str1=getHash(f1)
str2=getHash(f2)
return str1==str2
if __name__ == '__main__':
f1=open("F:文件地址/answer.json","rb")
f2=open("F:文件地址/answer.json","rb")
print(IsHashEqual(f1,f2))
python3 比较两个json文件内容是否一致,并输出不一致的内容
import json
f1=open("F:文件地址/answer.json","rb")
f2=open("F:文件地址/answer.json","rb")
json1 = json.load(f1)
json2 = json.load(f2)
for json1_list, json2_list in zip(json1, json2):
if json1_list != json2_list:
print(json1_list,json2_list)