i want to copy and paste a file into a directory so i use shutil library in python
file_path = 'C:/Users/user/Downloads/Telegram Desktop/speech.py'
target_path = 'C:/Users/user/Desktop/'
shutil.copyfile(file_path,target_path)
then i got that error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python39\lib\shutil.py", line 264, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: 'C:/Users/user/Desktop'
how can i fix this?
try/except, but then still You won't be able to do anything to the file, it just won't throw an error and stop Your code (also when usingtry/excepteither except the specific error or print out the exception to know what happened, DO NOT USE bareexcept:(suggestion))