[英]How to compare two html files and show only the differences in a new html file using python
I have used difflib but the html_table line is taking forever to execute. 我使用了difflib,但是html_table行花了很长时间才能执行。
import difflib
html_1 = data1
html_2 = data2
htmldiff = difflib.HtmlDiff()
html_table = htmldiff.make_table([html_1], [html_2])
I have tried htmldiffer but it is giving me ValueError: stat: path too long for Windows 我尝试了htmldiffer,但是它给了我ValueError:stat:Windows路径太长
from htmldiffer import diff
str_a = data1
str_b = data2
d = diff.HTMLDiffer(data1, data2)
print(d.combined_diff)
I have tried htmltreediff it is giving NameError: name 'basestring' is not defined 我试过htmltreediff它给出NameError:未定义名称'basestring'
from htmltreediff import diff
print (diff(data1, data2 , pretty=True))
This is how to make long file paths available on windows: https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/ 这是使长文件路径在Windows上可用的方法: https : //www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/
CPython issues related to difflib: 与difflib有关的CPython问题:
Solution for long chunks would be to split them into smaller parts and process separately. 长块的解决方案是将它们分成较小的部分并分别处理。 This way quadratic time will be smaller and we still can benefit from _fancy_helper logic. 这样二次时间会更短,我们仍然可以从_fancy_helper逻辑中受益。
htmltreediff
- does not support python 3 htmltreediff
不支持python 3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.