首页 > 解决方案 > 比较两个字符串并并排返回python中html中两个字符串之间的差异

问题描述

现在我difflib在 Python 中使用来生成不同的 html,

import difflib

htmlcontent = 
difflib.HtmlDiff(wrapcolumn=60).make_file(
        file_1, file_2, old_file.name, new_file,context=True)

with open(output_file, "w", encoding="utf8", errors='ignore') as f:
            f.write(htmlcontent)

问题 UI 不吸引人(UI 将根据 diff 从 html 文件呈现)。任何使 UI 更具吸引力的建议。或任何其他 python 库是否可以返回包含具有吸引力 UI 的差异的 html 模板,例如在线差异检查器?

标签: python

解决方案


推荐阅读