使用difflib.HtmlDiff类 - 显示单个字符
题
我使用的 difflib.HtmlDiff
类,主叫使用两个功能集文本(HTML来自网站)的,但是当它使表
html_diff = difflib.HtmlDiff()
print html_diff.make_table(previous_contents, fetch_url.page_contents)
然而,仅仅通过好像炭(每表行1个炭)来比较炭,和我结束了对两组的HTML其仅仅100K一个4.3MB txt文件。
在doc文件表示,
Compares fromlines and tolines (lists of strings) and returns a string which is a
complete HTML file containing a table showing line by line differences with
inter-line and intra-line changes highlighted.
然而,它似乎不是这种情况。
任何建议?
解决方案
您正在供给字符串,而不是串(行)的列表。
假设UNIX或Windows线端:
print html_diff.make_table(previous_contents.split('\n'),
fetch_url.page_contents.split('\n'))
不隶属于 StackOverflow