如何解决Python-运行时使用最新文件更新循环
是否有最佳方法来继续检查当前目录中的更新文件,并在运行时将该更新文件添加到循环中?
我尝试过的代码:
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:','D1.txt')
('The executing file is:','E1.txt')
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。