0
I researched, and I saw people doing like this:
import shutil
shutil.move("este-arquivo", "/tmp")
So I did it here in mine:
import shutil
shutil.move("arq.txt", "C:\Users\danielly.garcia\Desktop\pasta")
Only, the following error appears:
File "C:/Users/Danielly.Arcia/Desktop/test/Test 01.py", line 7 shutil.move("Arq.txt", "C: Users Danielly.Arcia Desktop folder") Syntaxerror: (error Unicode) 'unicodeescape' codec can’t Decode bytes in position 2-3: truncated UXXXXXXXX escape
I tried with them too:
import os os.rename("arq.txt",
"C:\Users\danielly.garcia\Desktop\pasta");
But it makes exactly the same mistake!
Related: What is the difference between 'string' and r'string in Python?
– Woss
There is relation to the marked answer but it is something kind of indirect, the problem she is having is precisely because of the U within "C: Users..." that Python is trying to escape as a Unicode character, when in reality it is not actually.
– Giovanni Nunes
The solution to the problem is simple, where there is a backslash you should put two of them, ie where you are
C:\Users\danielly.garcia\Desktop\pasta
should be 'C: Users Danielly.Arcia Desktop folder' (or if you need a more OS-independent solution use theos.path.join()
)– Giovanni Nunes