def ignore_list(path, files):
filesToIgnore = []
for fileName in files:
fullFileName = os.path.join(os.path.normpath(path), fileName)
if not os.path.isdir(fullFileName) and not fileName.endswith('pyc') and not fileName.endswith('ui') and not fileName.endswith('txt') and not fileName == '__main__.py' and not fileName == 'myfile.bat':
filesToIgnore.append(fileName)
return filesToIgnore
# Start of script
shutil.copytree(srcDir, dstDir, ignore=ignore_list)
복사 할 파일이 포함 된 if
행을 변경하고 싶습니다. 여기서 파일 이름을 별도로 지정해야하지만 모든 파일 이름이 들어있는 목록에서 파일 이름을 가져야하는 것처럼 변경하려고합니다.파일을 반복적으로 복사
어떻게하면됩니까?
파일 이름 목록은 어떻게 생겼습니까? 만약 무시할 파일 목록이라면'ignore ='에 그냥 넘기지 않으시겠습니까? – Bach
이 방법을 올바르게 사용하면 ignore_list가 경로 디렉토리를 통해 실행하고 if와 일치하는 파일을 찾아 복사하지 않아야하는 파일 목록을 반환해야합니다. – flazzarini
복사 할 파일이 "if"줄에 있습니다.이 줄이 필요하기 때문에 "if"조건 (* .pyc, * .txt, * .ui, __main__ 포함)이있는 "if"조건을 확인해야합니다. .py, myfile.txt) – Patrick