在Python中生成相当不同的html [英] Generate pretty diff html in Python

查看:129
本文介绍了在Python中生成相当不同的html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两大块文本,我想比较一下,看看哪些单词/行已经在Python中添加/删除/修改(类似于Wiki的差异输出)。

我已经尝试了difflib.HtmlDiff,但是它的输出并不漂亮。

在Python(或外部库)中有没有一种方法可以生成两组文本块的差异清晰的HTML? (不仅仅是行级别,还包括一行中的文字/字符修改)

解决方案 diff_prettyHtml( )位于 diff-match-patch 库中Google。


I have two chunks of text that I would like to compare and see which words/lines have been added/removed/modified in Python (similar to a Wiki's Diff Output).

I have tried difflib.HtmlDiff but it's output is less than pretty.

Is there a way in Python (or external library) that would generate clean looking HTML of the diff of two sets of text chunks? (not just line level, but also word/character modifications within a line)

解决方案

There's diff_prettyHtml() in the diff-match-patch library from Google.

这篇关于在Python中生成相当不同的html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆