不断在目录中搜索新文件Python

问题描述

我有一个脚本,该脚本会在出现在网络共享文件夹中时打印出.XSLX文件。一整天运行后,脚本在第二天早晨失败。

有什么方法可以使这种效率更高,或者24小时后不会失败?

这是脚本中处理目录扫描的部分:

import time
files = [f for f in os.listdir('.') if os.path.isfile(f)]
while True:
    for filename in files:
        if filename.endswith(".csv"):
            getCSV(filename)


            continue
        else:
            continue
    time.sleep(2)
    files = [f for f in os.listdir('.') if os.path.isfile(f)]
    print("searching..")

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)