How To Print The Comparison Of Two Multiline Strings In Unified Diff Format?
Do you know any library that will help doing that? I would write a function that prints the differences between two multiline strings in the unified diff format. Something like tha
Solution 1:
This is how I solved:
def_unidiff_output(expected, actual):
"""
Helper function. Returns a string containing the unified diff of two multiline strings.
"""import difflib
expected=expected.splitlines(1)
actual=actual.splitlines(1)
diff=difflib.unified_diff(expected, actual)
return''.join(diff)
Post a Comment for "How To Print The Comparison Of Two Multiline Strings In Unified Diff Format?"