我必須比較Python中的2個文件,我使用的是difflib。我試着分別與ndiff然後unified_diff。 2個文件的內容很簡單,每個例子here: File_1.txt: User1 US
User2 US
User3 US
File_2.txt: User1 US
User2 US
User3 NG
這裏是爲我的作品代碼(沒有正確的行號): import difflib
我有以下的數據幀 Column1 Column2
tomato fruit tomatoes are not a fruit
potato la best potatoe are some sort of fruit
apple there are great benefits to appel
pear peer
,我想查找的單詞/句子左邊與右邊的句子,如果有上最大前兩個
從兩個多行字符串中獲得差異的最佳方式是什麼? a = 'testing this is working \n testing this is working 1 \n'
b = 'testing this is working \n testing this is working 1 \n testing this is working 2'
diff = difflib.ndiff(a,b