#!/usr/bin/env python
# -*- coding: utf-8 -*-
import difflib
from difflib import *
def compare(stream1,stream2):
lines1 = stream1.splitlines()
lines2 = stream2.splitlines()
result=list(Differ().compare(lines1,lines2))
print str(result)
if __name__ == '__main__':
s1="hello\nword\nwww\n"
s2="hello\nworld"
compare(s1,s2)
转载于:https://www.cnblogs.com/code-style/archive/2012/03/13/2393825.html