This question is related to Python concatenate text files
I have a list of file_names, like [\'file1.txt\', \'file2.txt\', ...].
file_names
[\'file1.txt\', \'file2.txt\', ...].
I wou
You can use fileinput package. This module implements a helper class and functions to quickly write a loop over a list of files
import fileinput with fileinput.input(files=('file1.txt', 'file2.txt', 'file3.txt')) as f: for line in f: #rest code