本文共 550 字,大约阅读时间需要 1 分钟。
#!/usr/bin/env python
import difflib
import systry:
tx1 = sys.argv[1] tx2 = sys.argv[2] except Exception as e: print "error" + str(e) print "usage: xx filename1 filename2" sys.exit()def readf(fn):
try: fileH = open(fn, 'rb') text = fileH.read().splitlines() fileH.close() return text except Exception as e: print "error: " + str(e) system.exit()if name == "main":
tx1_line = readf(tx1) tx2_line = readf(tx2) d = difflib.HtmlDiff() print d.make_file(tx1_line,tx2_line)本文转自chenzudao51CTO博客,原文链接:http://blog.51cto.com/victor2016/2072143,如需转载请自行联系原作者