我尝试使用Python2.7集进行一些JSON文档比较。 我已经清理了py文档来理解set操作
在前面的代码中,我确保JSON文档具有精确的字段匹配
# convert the JSON to two set() for later operations
currSet = set(currJSON.items())
prevSet = set(prevJSON.items())
match = currSet & prevSet
unmatch = currSet ^ prevSet
log.info('%d, %d, Matched: %d, UnMatched: %d' % (len(currSet), len(prevSet), len(match), len(unmatch))
我总是得到len(currSet)==len(prevSet) 期望len(currSet)==len(匹配)+len(取消匹配)
^{pr2}$不应该:len(匹配)+len(umatch)==len(S1)
我脑子里有点不对劲。。。。在
您正在比较}的
union
和{sum
与仅one set
的长度相关问题 更多 >
编程相关推荐