Reputation: 17
path = "/work/Bible"
files= os.listdir(path)
txt = []
for file in files:
position =path+ '//' + file
print (position)
with open(position,"r+",encoding='utf-8') as f:
for line in f:
old_str = re.findall(r'\d+', line)
for i in range(0,len(old_str)):
line = line.replace(old_str[i],"\n"+"###### v"+old_str[i],1)
f.write(line)
I was going to add ####### before all the numbers in the text, but nothing happens when the last step writes to the original text. This question may be very beginner, but it bothers me, and I would appreciate the help.
Upvotes: 1
Views: 56