Generating and applying diffs in python

前端 未结 6 1345
野性不改
野性不改 2020-12-25 11:35

Is there an \'out-of-the-box\' way in python to generate a list of differences between two texts, and then applying this diff to one file to obtain the other, later?

<
6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-25 11:45

    AFAIK most diff algorithms use a simple Longest Common Subsequence match, to find the common part between two texts and whatever is left is considered the difference. It shouldn't be too difficult to code up your own dynamic programming algorithm to accomplish that in python, the wikipedia page above provides the algorithm too.

提交回复
热议问题