I have to replace multiple patterns and the piece of code is same for all. But, when I included it in the same .py file, all the patterns added aren't parsed and replaced. Is there a way to achieve this without having to create multiple .py files. Two samples added below, but I have nearly 7-8 conditions like this. I am using Python 3. Can anyone help please?
import glob
for filepath in glob.iglob('C:/Users/sh001/Desktop/tag/**/*.xml', recursive=True):
with open(filepath) as file:
s = file.read()
s = s.replace('</em>', '</i>')
with open(filepath, "w") as file:
file.write(s)
import glob
for filepath in glob.iglob('C:/Users/sh001/Desktop/tag/**/*.xml', recursive=True):
with open(filepath) as file:
s = file.read()
s = s.replace('</em>', '</i>')
with open(filepath, "w") as file:
file.write(s)