For loop Python-运行时使用最新文件更新循环
是否有一种最佳方法可以持续检查当前目录中的更新文件,并在运行时将该更新文件添加到循环中 我尝试过的代码:For loop Python-运行时使用最新文件更新循环,for-loop,For Loop,是否有一种最佳方法可以持续检查当前目录中的更新文件,并在运行时将该更新文件添加到循环中 我尝试过的代码: list = os.listdir(folder) #[A1.txt,B1.txt,C1.txt,D1.txt] #add E1.txt for i in list: time.sleep(10) with open(folder + i, "rb") as readdata: pr
list = os.listdir(folder)
#[A1.txt,B1.txt,C1.txt,D1.txt] #add E1.txt
for i in list:
time.sleep(10)
with open(folder + i, "rb") as readdata:
print("The executing file is:", i)
data = readdata.read()
Current Output:
('The executing file is:', 'A1.txt')
('The executing file is:', 'B1.txt')
('The executing file is:', 'C1.txt')
('The executing file is:', 'D1.txt')
Expected Output:
('The executing file is:', 'A1.txt')
('The executing file is:', 'B1.txt')
('The executing file is:', 'C1.txt')
('The executing file is:', 'D1.txt')
('The executing file is:', 'E1.txt')
有相同的问题,任何帮助有相同的问题,任何帮助