我是Python的新手,我创建了以下函数,根据列表中的项目(promptList)从目录(livepromptDir)复制文件)。到目前为止,它只将列表中的第一个项目复制到目标目录。请帮忙!提前致谢。如何从基于Python中的文件名列表中的项目目录复制文件
def copyItemToPrompt():
#This function will copy all of the appropriate Voice Prompt files from LivePrompts directory to promptDir based on promptList
os.chdir(livepromptDir)
try:
for i in range(0,len(promptList)):
for filename in fnmatch.filter(os.listdir(livepromptDir), promptList[i]):
shutil.copy(filename, promptDir)
return
except Exception as error:
log(logFile, 'An error has occurred in the copyLiveToPrompt function: ' + str(error))
raise
改变你回一个缩进背 – favoretti