python shutil复制文件权限错误

问题描述:

我想从一个文件夹复制图像到另一个文件夹使用shutil在python 3.6窗口10,但我正在运行许可错误。python shutil复制文件权限错误

我有我的源代码保存为一个名为“src”中包含

src = "C:/Users/marti/AppData/Roaming/vlc/art/artistalbum/artistname/art.jpg" 

和我的名为“SRC”目的地包含可变

dst = "C:/Users/marti/Desktop/MRL/cover" 

我的文件目前进口这些东西:

from shutil import copyfile 
from sys import exit 
import os 
import requests 

我正在使用此命令将src复制到目标:

copyfile(src, dst) 

但是当我运行这个程序,我给予了权限错误:

IOError: [Errno 13] Permission denied: 'C:/Users/marti/Desktop/MRL/cover/' 

甚至当我运行CMD以管理员身份,没有人知道如何编辑这些权限蟒蛇?

如果不是,我打开任何其他方法,这将允许我将图像从一个文件夹复制到另一个文件夹,并最终检查src字符串是否已更改,在这种情况下,它将删除dst文件夹中的图像并更换

+0

我不会,如果它是一个错字,但你的变量'src'中有空格字符。那么,'src'中的文件名在哪里? 'src = r“C:/Users/marti/Desktop/MRL/cover/art.jpg”'可能会更好。 – Kanak

+0

是的,这是一种类型的谢谢,但是当我修复它,并且没有空格的src时,我仍然得到这个错误信息:Traceback(最近调用最后一个): 文件“a.py”,第39行,在 getInfo() 文件“a.py”,第36行,在getInfo中 复制文件(src,dst) 文件“c:\ Python27 \ lib \ shutil.py”,第83行,复制文件 with open(dst,' wb')as fdst: IOError:[Errno 13] Permission denied:'C:/ Users/marti/Desktop/MRL/cover' – Martin

+0

@MartinBarker请将信息发布到您的问题,我们不知道temp_loc是这里有什么。你可以解释吗 ? – aircraft

shutil doc

Copy the contents (no metadata) of the file named src to a file named dst and return dst. src and dst are path names given as strings. dst must be the complete target file name; look at shutil.copy() for a copy that accepts a target directory path. If src and dst specify the same file, SameFileError is raised.

你要注意的dst must be the complete target file name