Write to yourself to see, afraid of their own forgotten
A project to get a transplant, which will involve the header file reference problem, a change too much trouble, decided to use Python regular match replacement. But I don't know how to access all the projects in a folder.
One, so the first step is to try to access all the files in the folder directory
In Python 2.7, Os.walk is used to complete
#coding =utf-8
Import OS
Import re
Dir= ' dir '
For root, subdirs, files in Os.walk (dir):
Print Root #,subdirs,files
Print files
For file in Files:
filename=root+ ' \ \ ' +file
F=open (filename, ' r+ ')
F.write (' Hello Fantasy ')
F.close ()
Root is the generator index to the iteration path, and the following files for the corresponding path of the file is the path can be directly accessed
Test all the files under the path are written to the Hello Fantasy
, because we only need to modify the application of the header file, so we can filter out some files
Come here today, next time.
Above
Python simple implementation fast regular replacement in engineering ~ ~ ~