f1 = open('a.txt', 'r')
s1 = f1.read()
f2 = open('b.txt', 'r')
s2 = f2.read()
ls = list(set(s1.split('\n')) & set(s2.split('\n')))
f3 = open('重叠部分.txt', 'w')
for i in ls:
f3.write(i)
f3.write('\n')
f1.close()
f2.close()
f3.close()
f1 = open('a.txt', 'r')
s1 = f1.read()
f2 = open('b.txt', 'r')
s2 = f2.read()
ls = list(set(s1.split('\n')) & set(s2.split('\n')))
f3 = open('重叠部分.txt', 'w')
for i in ls:
f3.write(i)
f3.write('\n')
f1.close()
f2.close()
f3.close()
相关课程