【问题标题】:Python: Reading a directory of 180 filesPython:读取 180 个文件的目录
【发布时间】:2022-06-10 22:33:00
【问题描述】:

我正在阅读一个包含 180 个文件的目录,并且每天都会添加一个文件。我需要先读取今天的所有文件,但明天我需要运行代码并且让它不返回任何已读取的旧文件。有没有办法做到这一点?这是我当前循环并遍历所有文件的循环。

#iterating through all the files
for file in os.listdir():
    #check if file is in .ls format or not
    if file.endswith(".ls"):
        filepath = f"{path}\{file}"
        #calling the read function
        axisMonitorAverage(filepath)

【问题讨论】:

  • 我很确定您总是要遍历所有文件以检查日期,例如,或者查看您昨天已经阅读过的文件

标签: python


猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-10
  • 2023-03-25
  • 2012-06-25
  • 2020-10-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多