以编程方式迭代文本差异中的块

时间:2016-05-17 07:15:39

标签: python diff patch

我在python中编程,我想知道是否有一种简单的方法来迭代(和解析)文本差异的各个块,由diff实用程序输出

伪python代码:

textdiff = diff('file1', 'file2') # Pretend this is a way of producing a diff
for chunk in textdiff:
    print('These lines are deleted: ', chunk.deletions)
    ... # And do some other interesting stuff with the extracted contents of the chunk.

0 个答案:

没有答案