comment puis-je préserver la structure du fichier après la substitution.Python ajoutant une nouvelle ligne à la fin de chaque ligne
# -*- coding: cp1252 -*-
import os
import os.path
import sys
import fileinput
path="C:\\Search_replace" # insert the path to the directory of interest
#os.path.exists(path)
#raise SystemExit
Abspath=os.path.abspath(path)
print(Abspath)
dirList=os.listdir(path)
print ('seaching in',os.path.abspath(path))
for fname in dirList:
if fname.endswith('.txt') or fname.endswith('.srt'):
#print fname
full_path=Abspath+"\\"+fname
print full_path
for line in fileinput.FileInput(full_path,inplace=1):
line = line.replace("þ","t")
line=line.replace("ª","S")
line=line.replace("º","s")
print line
print "done"
Uhhhh ... . quelle? – rossipedia