def copyFileBtnClick(self): srcFilePath = unicode(self.srcFilePathEdit.text()) destFilePath = unicode(self.destFilePathEdit.text()) fileListEdit = str(self.fileListEdit.toPlainText()) if not fileListEdit: tips = unicode("请在文件集合框中输入拷贝文件路径") self.setTips(_fromUtf8(tips)) return srcFilePath = (srcFilePath if srcFilePath.strip() else str("Y:\\work_src\\gitlab\\I13\\HLOS")) destFilePath = (destFilePath if destFilePath.strip() else str("G:\\copyfile")) FileUtil.mkdirNotExist(destFilePath) # print fileListEdit # .* 匹配除换行符 \n 之外的任何字符 \S 匹配任何非空白字符, 此处用来匹配保存在string中的文件目录格式 reFileStr = r'(.*\S)' fileList = re.findall(reFileStr, fileListEdit) if not fileList: tips = unicode("没有在文件集合中找到文件路径") self.setTips(_fromUtf8(tips)) return for fileName in fileList: if not fileName: continue if fileName.startswith("/") or fileName.startswith("\\"): fileName = fileName[1:] fileName = fileName.replace("/", "\\") # srcFile = os.path.join(srcFilePath, fileName) # destFile = os.path.join(destFilePath, fileName) # print 'srcFilePath: ', srcFile # print 'destFile: ', destFile FileUtil.copyFile(srcFilePath, destFilePath,srcFilePath, fileName) tips = unicode("拷贝完成: ") + destFilePath self.setTips(_fromUtf8(tips)) self._runSysCmd.run(['explorer.exe', destFilePath])