1. 程式人生 > >python文字資訊對比

python文字資訊對比

使用python實現對兩個文字資訊的對比,檢視文字更新、差異

import difflib

text1 = """ """
text2 = """ """

text1_lines = text1.splitlines()
text2_lines = text2.splitlines()

d = difflib.Differ()
diff = d.compare(text1_lines, text2_lines)

print("\n".join(list(diff)))