python字典值比较脚本

来源:互联网 发布:java面试电商项目逻辑 编辑:程序博客网 时间:2024/06/07 17:51
#coding=utf8import loggingimport osfrom Lib.DealCsv import ExceptPropertyDicfrom wxPython._wx import false'''用于json数据的比较,包含属性、属性值的比较。'''#用于比较字符串、列表PATH=lambda p:os.path.abspath(os.path.join(    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         #参数包含两个:#containVar:查找包含的字符#stringVar:所要查找的字符串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) for val in var.split("|")]        notContainSeparatorList=[var for var in exceptDic.values() if not containVarInString("|",var)]        exceptValueList=notContainSeparatorList+containSeparatorList        FalseBool=list(set([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' : 'track' ,    'serviceId' : 'pageview' ,    'srcSubModule' : '声音条' ,    'srcPosition' : 'XX',    'srcPage' : '发现_推荐' ,    'srcPageId' : 'XX' ,    'srcModule' : '焦点图' ,    'srcTitle' : '焦点图标题' ,    'focusId' : '焦点图ID'       }   ExpecDic={    'itemId ': 'XX',    'item' : 'track' ,    'serviceId' : 'pageview' ,    'srcSubModule' : '声音条' ,    'srcPosition' : 'XX',    'srcPage' : '发现_推荐|猜你喜欢|订阅' ,    'srcPageId' : 'XX' ,    'srcModule' : '焦点图' ,    'srcTitle' : '焦点图标题' ,    'focusId' : '焦点图ID'       }     if __name__=="__main__":        if CmpValue(propsDic, ExpecDic):        print "Equel"    else:        print "not equel"        

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 真空杯不保温了怎么办 锅底外面烧黑了怎么办 锅底里面烧黑了怎么办 佳能50镜头跑焦怎么办 g7x镜头进灰了怎么办 leica镜头进灰了怎么办 请问喉咙痒咳嗽该怎么办 喉咙痒咳嗽有痰怎么办 痒咳嗽停不下来怎么办 嗓子疼咳嗽有痰怎么办 上火了喉咙干痒怎么办 喉咙里总是有痰怎么办 1岁宝宝喉咙有痰怎么办 嗓子总感觉有痰怎么办 嗓子痒感觉有痰怎么办 1岁宝宝嗓子有痰怎么办 3岁宝宝嗓子有痰怎么办 喉咙总感觉有痰怎么办 感冒了喉咙有痰怎么办 咽喉有异物感是怎么办 老感觉喉咙有痰怎么办 感冒有痰怎么办最有效 感冒快好了有痰怎么办 喉咙里一直有痰怎么办 一到晚上就咳嗽怎么办 1岁宝宝咳嗽痰多怎么办 3岁宝宝咳嗽痰多怎么办 六岁儿童咳嗽有痰怎么办 很多白痰在喉咙怎么办 我喉咙总是有痰怎么办 喉咙老感觉有痰怎么办 喉咙痒老是有痰怎么办 抽烟多了嗓子疼怎么办 抽烟多了老咳嗽怎么办 抽烟抽多了咳嗽怎么办 嗓子咳出异物臭怎么办 鼻子有鼻涕喉咙有痰怎么办 怀孕39周感冒了怎么办 一口痰卡在喉咙怎么办 鼻塞黄鼻涕黄痰怎么办 小孩咳嗽流黄鼻涕怎么办