this article illustrates the dictionary value comparison function of the Python implementation. Share to you for your reference, as follows:

 #coding=utf8 import logging import OS from Lib.DealCsv import ExceptPropertyDic from wxPython._wx import false 'for JSON data, including comparison of properties and property values. For comparison, '# string list PATH=lambda (os.path.join p:os.path.abspath (os.path.dirname (__file__), P logging.basicConfig (level=logging.DEBUG)), format='% (asctime) s% (filename) s[line:% (lineno) d]% (levelname) s% (message) S', datefmt='%a,%d%b%Y%H:%M:%S'filename=PATH ('../Log/judgeProps.log'), filemode='w'DEF) CmpObj (reaResultl, exceptResult): try: if len (reaResultl) ==len (exceptResult): if CMP (reaResultl, exceptResult) ==0: return True else: return False else: return False except Exception, e: print e # contains two parameters: #containVar: #stringVar: the search contains the character string to search for def containVarInString (containVar stringVar: try:). If isinstance (stringVar, STR): if containVar in stringVar: return True else: return False else: return False except Exception, e: print e def CmpValue (propsDic, exceptDic): try: containSeparatorList=[val for VaR in exceptDic.values (if) containVarInString ("|", VAR Val in var.split (for) "|")] notContainSeparatorList=[var for VAR in exceptDic.values (if) not containVarInString ("|", VAR exceptValueList=notContainSeparatorList+containSeparatorList FalseBool (set)] =list ([False for VaR in propsDic.values (if) var not in exceptValueList ")) if len (FalseBool): return False else: return True except Exception, e: print e propsDic={'itemId ':'XX','item':'trac K','serviceId':'pageview','srcSubModule': 'voice','srcPosition':'XX','srcPage':' found _ recommended ','srcPageId':'XX','srcModule': ''srcTitle' ': focus map' focus map title ''focusId': 'ID' ExpecDic={'itemId '} focus map:'XX','item':'track','serviceId':'pageview','srcSubModule':' voice ','srcPosition':'XX','srcPage': '_ recommended | guess you found love | subscription','srcPageId':'XX','srcModule':''srcTitle'': focus map 'focus map title''focusId'': ID'} if __name__== focus map "__main__": print "home test script results: if CmpValue (propsDic, ExpecDic): print" Equel "else:" print not equel "

 and

Python more about the related content of interested readers can view the topic:" Python "dictionary operation skills summary," Python data structure and algorithm tutorial "and" Python encryption and decryption algorithm and , "Python ", encoding skills summary" Python ", summarizes the skills in the use of function" Python "string manipulation skills summary and" Python and "advanced introductory tutorial classic

hope in this paper, the Python program designed to help all of you.


This concludes the body part