I need it for make that the rest of my code works I need replace the spaces for " " because it is a #linux directory path so I've tried with the method str.replace()
and the method re.sub()
but always that is replaced return "\ " instread of " " because "\ " in python writing mean " " but I don't need "\ " i need " " how i can replace " " for " "? it′s the part of code that replace the path:
from datetime import date
import os
import re
from os import listdir
import shutil
from os.path import isfile, join
ruta_de_descragas = "/home/carloseduardopalmalicea/Descargas/"
def listfdesc():
listfdesc.onlyfiles = os.listdir(path=ruta_de_descragas)
inh = list(range(0,len(listfdesc.onlyfiles)))
for i in inh:
listfdesc.onlyfiles[i] = re.sub(" "," ",listfdesc.onlyfiles[i])
question from:
https://stackoverflow.com/questions/65839504/python-re-sub-str-return-instread-of 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…