trnnr.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:trnnr 作者: NullHypothesis 项目源码 文件源码
def format_desc(desc, ref_desc, use_colour):
    """
    Return potentially colourised string list of descriptor features.
    """

    desc, ref_desc = desc_to_str(desc), desc_to_str(ref_desc)
    final_string = ""

    for string, ref_string in zip(desc.split(","), ref_desc.split(",")):
        for char, ref_char in itertools.zip_longest(string, ref_string):

            # If a character in the string is identical to the reference
            # string, we highlight it in red.  That makes it easier to visually
            # spot similarities in the descriptors.

            if (char == ref_char) and use_colour:
                final_string += termcolor.colored(char, "red")
            else:
                final_string += char if char is not None else " "

        final_string += ","

    return final_string.split(",")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号