Join Text Files In Python
Join the DZone community and get the full member experience.Join For Free
// join contents of text files in current directory
import os filenames = os.listdir('.') content = '' for f in filenames: content = content + '\n' + open(f).read() open('joined_file.txt','wb').write(content)
Opinions expressed by DZone contributors are their own.