下面函数是逐行读取文件,然后进行不同对比
def bijiao(a,b):
alist=[]
blist=[]
for line in open(a):
alist.append(line)
for line in open(b):
blist.append(line)
print("a have b not have")
print(set(alist).difference(set(blist)))
print("b have a not have")
print(set(blist).difference(set(alist)))
a='/Users/cf/Downloads/a.txt'
b='/Users/cf/Downloads/b.txt'
bijiao(a,b)
更多精彩代码请关注我的专栏
关键词
程序员 方向 云计算 前途 微信 毕设 学霸 能量
网友评论