我想做一个三部分的程序。我有两个文本文件,文本文件A和文本文件B
文本文件A必须将数据与文本文件B进行比较。如果有重复,它将通过电子邮件发送给它。 如果没有重复,它将数据写入文本文件B
我遇到的问题是,复制总是从文本文件的开头开始。我试图找到代码,从它检查的最后一行开始。在
这是我的复制码。在
f1 = open("/path/to/file1", "r")
f2 = open("/path/to/file2", "r")
txtfileA = f1.read()
txtfileB = f2.read()
txtfileA_words = txtfileA.split()
txtfileB_words = txtfileB.split()
result = set(textfileA_words).difference(set(txtfileB_words))
print result
有没有更好的密码,我做错什么了吗?在
任何建议都会很好。在
你应该使用交集函数,而不是差分函数。另外,变量名有一个错误。在
您可以使用:
相关问题 更多 >
编程相关推荐