Friday, 22 February 2019

compare two different paragraph line by line in Python


from difflib import HtmlDiff

text_A= """
1) line number 1
2) line number 2
3) line number n
"""

text_B= """
2) line number 2
3) line number n
4) line number raghu
"""




delta_html = HtmlDiff().make_file(text_A.splitlines(),
                                  text_B.splitlines())

with open('diff.html', 'w') as f:
     f.write(delta_html)

No comments:

Post a Comment

Git

1 git add ↳ It lets you add changes from the working directory into the staging area 2 git commit ↳ It lets you save a snapshot of currently...