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

前端 未结 13 2018
抹茶落季
抹茶落季 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:14

    os.stat https://docs.python.org/2/library/stat.html#module-stat

    edit: In newer code you should probably use os.path.getmtime() (thanks Christian Oudard)
    but note that it returns a floating point value of time_t with fraction seconds (if your OS supports it)

提交回复
热议问题