0%
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| import os
def addAsciiHeadFile(asciiFolder): rootdir = os.path.join(asciiFolder) for (dirpath, dirnames, filenames) in os.walk(rootdir): for filename in filenames: if os.path.splitext(filename)[1] == '.txt': asciiPath=asciiFolder+"\\"+filename with open(asciiPath, 'r+') as f: content = f.read() f.seek(0, 0) f.write('XXX\n' + 'XXX\n' + 'XXX\n' + 'XXX\n' + 'XXX\n' + 'XXX\n' + content) print asciiPath + "done!"
|