我是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