Overview:
- The context diff format returned by the context_diff() method is same as the one emitted by the GNU diff tool.
- The context diff format marks the changed lines with a ! symbol, leaving the unchanged lines without any marking. The GNU diff tool shows few lines of context around the text that has changed.
Example:
|
# Example Python program that displays the import difflib # Text lines to be compared text2 = ["And learn, too late, they grieved it on its way,", # Find the differences in context diff format # Print the differences in context diff format |
Output:
|
The contextual difference: --- to.txt *************** *** 1,2 **** ! Because their words had forked no lightning they ! And learn, too late, they grieved it on its way, |