美文网首页
【python】 两个list value值比较, 若需要比较

【python】 两个list value值比较, 若需要比较

作者: GovS_777 | 来源:发表于2018-09-19 00:58 被阅读0次
    # 两个list value值比较
    def check_list(self, list01, list02):
        """
        两个list value值比较, 若需要比较两个list值是否都互相包含,则替换参数顺序调用两次接口。
        :param list01: 
        :param list02: 
        :return: 
        """
        for x in list01:
            if x not in list02:
                self.Verify.should_contain(list02, x)
                return False
        return True

#  引用示例
check_result01 = self.check_list(expect_jsonkeys, response_json_keys)
check_result02 = self.check_list(response_json_keys, expect_jsonkeys)
if (not check_result01) or (not check_result02):
    logger.error("%s keys compare failed:\n***********expect keys:\n%s\n***********"
                 "response keys:%s" % (api, expect_jsonkeys, response_json_keys))

相关文章

网友评论

      本文标题:【python】 两个list value值比较, 若需要比较

      本文链接:https://www.haomeiwen.com/subject/bshbnftx.html