在我下面的函数中,run_check是一个全局列表。当我在下面追加文件时,文件被追加的次数与处理列表中的文件一样多。
如果第三个循环中的run_check语句不是真的,那么是否有一种方法只将文件追加到if?
def lookForProcessingFiles(ctf,gcc):
processingList = []
for file in os.listdir(Incoming_Data):
if (file[:32] == ctf[:32]) and (file[:32] == gcc[:32]):
processingList.append(file)
for x,y in itertools.combinations(processingList,2):
if (x[:58] == y[:58]) and x.endswith('.raw') and y.endswith('.csv'):
#checkDict()
#move y then move x to input folder
print(x,y)
for file in processingList:
if (file[:32] == ctf[:32]) and (file[:32] == gcc[:32]) and file.endswith('last.txt'):
#checkDict()
#move file to input
#remove files from runs_dict
print('Last: ' + file)
else:
#runs_dict.update({'CTF: ' + ctf[8:27]:ctf, 'GCC: ' +gcc[8:27]:gcc})
run_check.append(ctf)
run_check.append(gcc)发布于 2020-06-23 20:28:50
使用any()测试所有文件。
if not any(file[:32] == ctf[:32]) and (file[:32] == gcc[:32]) and file.endswith('last.txt') for file in processingList):
run_check.append(ctf)
run_check.append(gcc)https://stackoverflow.com/questions/62543149
复制相似问题