I need to search in a parent folder all files that are config.xml and in those files replace one string in another. (from this-is to where-as)
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
You want to take a look at
os.walk()
for recursively traveling through a folder and subfolders.Then, you can read each line (
for line in myfile: ...
) and do a replacement (line = line.replace(old, new)
) and save the line back to a temporary file (tmp.write(line)
), and finally copy the temp file over the original.Hope this is what you are looking for.