简单的文件比对得出相同的结果并输出文件

#!/usr/bin/python
# -*- coding: utf-8 -*-
import json

with open('file-0704.txt', 'r') as file1:
    with open('file-0730.txt', 'r') as file2:
        wantfiles = set(file1).intersection(file2)

wantfiles.discard('\n')

with open('output_file.txt', 'w') as file_out:
    for line in wantfiles:
        file_out.write(line)

你可能感兴趣的:(简单的文件比对得出相同的结果并输出文件)