1

我正在尝试合并一个文件并对其进行一些更改。例如,如果我有文件:

This is Line 1
This is Line 2
This is Line 3

我已将其更改为:

This is Line 1
This is Line 3
This one is another line

我将从以下位置获取此输出difflib.unified_diff

--- test.txt
+++ test2.txt
@@ -29,1 +29,1 @@
-2+3@@ -36,0 +36,4 @@
+o+n+e+ @@ -39,1 +43,9 @@
-L+a+n+o+t+h+e+r+ +l@@ -43,2 +55,0 @@
- -3

我希望能够仅获取此输出和原始文件,并将它们合并到获取第二个文件中。

有什么办法可以做到这一点?

4

1 回答 1

1

最后,我找到了一个名为“diff_match_patch”的库,它正是我一直在寻找的。在这里查看更多信息: https ://code.google.com/archive/p/google-diff-match-patch/

于 2016-02-28T05:55:57.177 回答