pycharm 执行shutil.copy()闪退
import os
import shutil
import sys
from PyQt5.QtWidgets import *
from PyQt5 import QtWidgets,QtCore
import teswindow
class checkB(QtWidgets.QMainWindow, teswindow.Ui_MainWindow):
def init(self):
super().init()
self.setupUi(self)
self.toolButton.clicked.connect(lambda : self.select_file())
self.pushButton.clicked.connect(lambda : self.save_file())
def select_file(self):
self.files, ok1 = QFileDialog.getOpenFileNames(self,"多文件选择","./","All Files (*);;Text Files (*.txt)")
for f in self.files:
self.textBrowser.append(f)
def save_file(self):
project_name=str(self.textEdit.toPlainText())
chil_name_D = str("底类")
path_base = "E:\\testspace"
if project_name != "":
dir_name = path_base + '/' + project_name
if project_name not in os.listdir(path_base):
os.mkdir(dir_name)
else:
messagebox.showerror("警告", "存在同名文件夹,请重新输入!")
else:
messagebox.showerror("警告", "请输入项目名称!")
if self.checkBox.isChecked():
os.mkdir(path_base + '/' + project_name + '/' + chil_name_D)
for t in self.files:
base_path = 'r' + "\'" + str(t) + "\'"
final_path = 'r' + "\'" + path_base + "\\" + project_name + "\\" + chil_name_D +"\'"
final_path=os.path.join(final_path,os.path.basename(base_path))
shutil.copyfile(base_path, final_path)
# print(base_path)
# print(final_path)
app = QApplication(sys.argv)
w = checkB()
w.show()
sys.exit(app.exec_())
File ".code.tio", line 1 self.toolButton.clicked.connect(lambda : self.select_file()) ^ IndentationError: unexpected indent
跟ide没关系,是你代码有问题