with open("File1.txt") as fin1: lines = set(fin1.readlines())
with open("File2.txt") as fin2: lines.update(set(fin2.readlines()))
with open("file3.txt", 'w') as fout: fout.write('\n'.join(list(lines)))
How to perform an union of two files containing keywords in python?
-
12-10-2022 - |
Вопрос
I have 2 different text files.
File1.txt contains:
program
RAM
Python
parser
File2.txt contains:
file
1234
program
I want to perform an union of these both files such that i get an output file3.txt which contains:
program
RAM
Python
parser
file
1234
Is it possible to program this in python? I use python 2.7
Решение
Не связан с StackOverflow