を使用して 2 つのシーケンスを比較しようとしていdifflib.Differ()
ます。ただし、理解できない望ましくない違いがいくつか見られます。誰かがこの動作とこれを解決する方法を説明できますか?
import difflib
a = "abc-123 Abcdef"
b = "abc-123 Abcdef-def"
a = a.strip("\n")
b = b.strip("\n")
a = a.split(" ")
b = b.split(" ")
d = difflib.Differ()
result = list(d.compare(a,b))
for s in result:
if s[0] == ' ':
continue
print s
出力:
- Abcdef
+ Abcdef-def
? ++++
?
ここで違いが報告されているのはなぜですか? 最初の 2 つの相違点のみが報告されることを期待しています (変更のみ)。