comparing two text files and remove duplicates in python
问题 I have two text files, file1 and file2 . File1 contains a bunch of random words, and file2 contains words that I want to remove from file1 when they occur. Is there a way of doing this? I know I probably should include my own attempt at a script, to at least show effort, but to be honest it's laughable and wouldn't be of any help. If someone could at least give a tip about where to start, it would be greatly appreciated. 回答1: get the words from each: f1 = open("/path/to/file1", "r") f2 = open