当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python difflib.restore用法及代码示例


用法:

difflib.restore(sequence, which)

返回生成增量的两个序列之一。

给定由 Differ.compare()ndiff() 生成的 sequence,提取源自文件 1 或 2(参数 which )的行,去除行前缀。

例子:

>>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True),
...              'ore\ntree\nemu\n'.splitlines(keepends=True))
>>> diff = list(diff) # materialize the generated delta into a list
>>> print(''.join(restore(diff, 1)), end="")
one
two
three
>>> print(''.join(restore(diff, 2)), end="")
ore
tree
emu

相关用法


注:本文由纯净天空筛选整理自python.org大神的英文原创作品 difflib.restore。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。