Sorting files by date

后端 未结 1 1898
故里飘歌
故里飘歌 2020-12-30 12:25

I found this directory checking code on the web and modified it a little, so it would print out added files. There\'s a buoy that sends me readings every now-and-then, but s

相关标签:
1条回答
  • 2020-12-30 12:38
    added.sort(key=lambda x: os.stat(os.path.join(path_to_watch, x)).st_mtime)
    

    Will sort the added list by the last modified time of the files

    Use st_ctime instaed of st_mtime for creation time on Windows (it doesn't mean that on other platforms).

    0 讨论(0)
提交回复
热议问题