Overview:
- The ndiff() function of Python difflib module returns a generator object containing differences between two lists of strings.
- Each difference is listed in the format <opcode, string>.
- When the opcode is '- ' the string is present only in the first string and when it is '+ ' the string is present only in the second string.
- If the opcode is ' ' there is no difference between the strings. The opcode '? ' represents the intra-line difference between two strings.
Example:
|
# Example Python program that finds the difference # Create two lists of strings # Find the differences print(diffs) |
Output:
| <generator object Differ.compare at 0x102f84cc0> <class 'generator'> Hello - World + Friends |