问题 I'm using difflib 's SequenceMatcher to get_opcodes() and than highlight the changes with css to create some kind of web diff . First, I set a min_delta so that I consider two strings different if only 3 or more characters in the whole string differ, one after another ( delta means a real, encountered delta, which sums up all one-character changes): matcher = SequenceMatcher(source_str, diff_str) min_delta = 3 delta = 0 for tag, i1, i2, j1, j2 in matcher.get_opcodes(): if tag == "equal":