Outputs Python files joined

import os for root, dirs, files in os.walk("dir_example/"): for file in files: if file.endswith(".py"): file = os.path.join(root, file) with open(file, 'r') as content: f = open('output_file', 'a') f.write('filename: ' + str(file) + '\n') f.write('\n') f.write(content.read()) f.close()
Join the content of all Python files within a directory and outputs to a single text file.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.