Python Difflib Module
Sequence comparison — SequenceMatcher, get_close_matches, unified_diff. This category documents 6 Python difflib module entries, and each page gives you the full syntax, the parameter list, the return value, and a runnable example. The entries include: difflib.SequenceMatcher(), difflib.get_close_matches(), difflib.unified_diff(), difflib.context_diff(), difflib.ndiff(), difflib.HtmlDiff(). difflib.SequenceMatcher() flexible sequence comparison object. Finds the longest matching subsequences. difflib.get_close_matches() returns the best `n` matches for a word from a list of possibilities. difflib.unified_diff() compares two sequences and produces a unified diff output (like diff -u). difflib.context_diff() compares sequences and produces a context diff (like diff -c). difflib.ndiff() compares sequences and produces a human-readable delta (like diff). For a structured walkthrough of the whole topic, read the Difflib Module guide. Difflib Module belongs to the Text & Regex group alongside Regex Module, Textwrap Module, Unicodedata Module, HTML Module. You can also search across every category from the search page, browse the complete A–Z index, or try any example in the Python playground.