Python Forum

Full Version: Copying a file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
import shutil
shutil.copy(“\\Om-pc\e\Office File\Access Original 14-16\Cash MAR.2017 TO APR.2019.accdb”, "C:\Users\KUNDAN\Desktop\Cash MAR.2017 TO APR.2019.accdb ")
The above code is giving the following error:
Traceback (most recent call last):
File "C:\Users\KUNDAN\backup.py", line 2
shutil.copy(“\\Om-pc\e\Office File\Access Original 14-16\Cash MAR.2017 TO APR.2019.accdb”, "C:\Users\KUNDAN\Desktop\Cash MAR.2017 TO APR.2019.accdb ")
^
SyntaxError: invalid character in identifier
Use Code tag.
You are mixing left double quotation mark with ordinary quotation mark.
Next error will be here C:\U,do not use single backslash \ in path because of escape character.

Fixed it would be like this.
import shutil

shutil.copy("\\Om-pc\e\Office File\Access Original 14-16\Cash MAR.2017 TO APR.2019.accdb", r"C:\Users\KUNDAN\Desktop\Cash MAR.2017 TO APR.2019.accdb")