How to get file creation & modification date/times in Python?

前端 未结 13 2019
抹茶落季
抹茶落季 2020-11-21 11:44

I have a script that needs to do some stuff based on file creation & modification dates but has to run on Linux & Windows.

13条回答
  •  时光取名叫无心
    2020-11-21 12:18

    It may worth taking a look at the crtime library which implements cross-platform access to the file creation time.

    from crtime import get_crtimes_in_dir
    
    for fname, date in get_crtimes_in_dir(".", raise_on_error=True, as_epoch=False):
        print(fname, date)
        # file_a.py Mon Mar 18 20:51:18 CET 2019
    

提交回复
热议问题