Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
wxPython空间中的cp拷贝_Python_Wxpython_Cp - Fatal编程技术网

wxPython空间中的cp拷贝

wxPython空间中的cp拷贝,python,wxpython,cp,Python,Wxpython,Cp,在我正在制作的一个小型wxPython程序中,我有一个for循环,它获取文件列表中的项目,并使用cp copy进行复制。一切都很好,并且在路径中没有空间的源上工作。但是,当引入源代码时,cp函数无法找到我的源代码。 这是我的密码: if f_name in selectedsecondcource: self.counter += 1 self.toPrint = self.counterText + str(self.counter) + "/" + str(len(selec

在我正在制作的一个小型wxPython程序中,我有一个for循环,它获取文件列表中的项目,并使用cp copy进行复制。一切都很好,并且在路径中没有空间的源上工作。但是,当引入源代码时,cp函数无法找到我的源代码。 这是我的密码:

if f_name in selectedsecondcource:
    self.counter += 1
    self.toPrint = self.counterText + str(self.counter) + "/" + str(len(selectedList))
    self.oncopy.SetLabel(self.toPrint)
    src_abs_path = os.path.join(r, file)
    src_relative_path = os.path.relpath(src_abs_path, self.twoDirFilename)
    dst_abs_path = os.path.join(self.DirDest, src_relative_path)
    dst_dir = os.path.dirname(dst_abs_path)
    if not os.path.exists(dst_dir):
        os.makedirs(dst_dir)
    ret = os.system('cp -fr %s %s' % (src_abs_path, dst_abs_path))
感谢您的帮助。 虽然这是我的第一个Python程序,但我对Python的理解比这个OS.system('cp…之类的东西)要好

简言之:如何在目录名中有空格的源上实现这一点

谢谢
Gavin

正常,如果文件名之间用空格分隔,则该命令无效

尝试使用引号:

ret = os.system('cp -fr "%s" "%s"' % (src_abs_path, dst_abs_path))
但这更好: