1. Compare Diff_text Two text differences by HTML
#!/usr/bin/env python
Import Difflib
Text1 = "" "Text1:
This module provides classes and functions for comparing sequences.
including HTML and context and unified diffs.
Difflib Document v7.4
Add string
"""
Text1_lines = Text1.splitlines ()
Text2 = "" "Text2:
This module provides classes and functions for comparing sequences.
including HTML and context and unified diffs.
Difflib Document v7.5
"""
Text2_lines = Text2.splitlines ()
D = difflib. Htmldiff ()
Print D.make_file (Text1_lines, Text2_lines)
2. Compare by difference relationship
#!/usr/bin/env python
Import Difflib
Text1 = "" "Text1:
This module provides classes and functions for comparing sequences.
including HTML and context and unified diffs.
Difflib Document v7.4
Add string
"""
Text1_lines = Text1.splitlines ()
Text2 = "" "Text2:
This module provides classes and functions for comparing sequences.
including HTML and context and unified diffs.
Difflib Document v7.5
"""
Text2_lines = Text2.splitlines ()
D = difflib. Differ ()
diff = D.compare (text1_lines, Text2_lines)
print ' \ n '. Join (List (diff))
Learn Python automated operations Diff-text