def diff_word_get(): '''按照词比较两个文件不同''' with open('lfile.tmp') as fd: lfile = fd.read() lfile = list(jieba.cut(lfile)) with open('rfile.tmp') as fd: rfile = fd.read() rfile = list(jieba.cut(rfile)) return diff_ctx(lfile, rfile)
def diff_line_get(): '''按照行比较两个文件不同''' with open('lfile.tmp') as fd: lfile = fd.read() lfiles = [line.strip() for line in lfile.splitlines()] with open('rfile.tmp') as fd: rfile = fd.read() rfiles = [line.strip() for line in rfile.splitlines()] return diff_ctx(lfile, rfile)
def diff_get(): try: with open('lfile.tmp') as fd: lfile = fd.read() with open('rfile.tmp') as fd: rfile = fd.read() return diff_ctx(lfile, rfile) except: return {}