我有以下代码:
if inputFileName:
if inputFileName.lower().endswith(mediaExt):
for word in ignoreWords:
if word not in inputFileName.lower():
if os.path.isfile(inputDirectory):
try:
processFile(fileAction, inputDirectory, outputDestination)
except Exception, e:
logging.error(loggerHeader + "There was an error when trying to process file: %s", os.path.join(inputDirectory, inputFileName))
logging.exception(e)
else:
try:
processFile(fileAction, os.path.join(inputDirectory, inputFileName), outputDestination)
except Exception, e:
logging.error(loggerHeader + "There was an error when trying to process file: %s", os.path.join(inputDirectory, inputFileName))
logging.exception(e)
ignoreWords 是一个列表,其中包含一些我不希望文件名包含的单词。现在我的问题是这将循环遍历列表中 x 项的相同文件。我希望它只匹配一次单词(或在匹配完成后运行一次 processFile)但不太能够找到合适的解决方案