Python Scp копировать файл с пробелами в имени файла

Я пытаюсь скопировать файлы в локальной сети с помощью scp. Он хорошо работает с именами файлов без пробелов, но с ошибкой. Я пытался заменить "" на "\", как этоExemple, но это не работает. Вот мой код:

def connection(locals):
         a = (int(re.search(br'(\d+)%

Как я могу решить эту проблему? Спасибо

, locals['child'].after).group(1))) print a perc = (Decimal(a)/100) print (type(perc)), perc while gtk.events_pending(): gtk.main_iteration() FileCopy.pbar.set_text("Copy of the file in the Pi... " + str(a) + "%") while gtk.events_pending(): gtk.main_iteration() FileCopy.pbar.set_fraction(perc) file_pc = "/home/guillaume/folder/a very large name of file with space .smthg" file_pi = "[email protected]:/home/pi/folder/a very large name of file with space .smthg" if " " in file_pc: file_pc = fichier_pc.replace(" ", '\\\ ') # tried '\\ ' or '\ ' file_pi = fichier_pi.replace(" ", '\\\ ') # but no way else: pass command = "scp %s %s" % tuple(map(pipes.quote, [file_pc, file_pi])) pexpect.run(command, events={r'\d+%': connection}) # this command is using to get the %

Как я могу решить эту проблему? Спасибо

Ответы на вопрос(3)

Ваш ответ на вопрос