我必须比较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