find duplicate words in two files [closed]
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 years ago . I've two text files. I need to check for duplicate words inside them. Is there a way more concise than this code? file1 = set(line.strip() for line in open('/home/user1/file1.txt')) file2 = set(line.strip() for line in open('/home/user1/file2.txt')) for line in file1 & file2: if line: print(line)