Python mobile file reported an error with escape characters in the path




watermark is get over
/home/shenjianlin/pdf_file/:,.pdf


Traceback (most recent call last):
  File "/usr/lib64/python3.4/shutil.py", line 527, in move
    os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: "/home/shenjianlin/pdf_file/:,.pdf" -> "home/shenjianlin/pdf_file/trash_pdf_file"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "remove_water_mark.py", line 89, in <module>
    remove_water_mark().read_content()
  File "remove_water_mark.py", line 78, in read_content
    shutil.move(file, self.trash_pdf_path)
  File "/usr/lib64/python3.4/shutil.py", line 539, in move
    copy2(src, real_dst)
  File "/usr/lib64/python3.4/shutil.py", line 245, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib64/python3.4/shutil.py", line 108, in copyfile
    with open(src, "rb") as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: "/home/shenjianlin/pdf_file/:,.pdf"

how to deal with the escape characters here, because the for circular folder cannot be used, and the file names are stored in variables

.
Feb.09,2022

Please bring up the code

Menu