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

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

    os.stat does include the creation time. There's just no definition of st_anything for the element of os.stat() that contains the time.

    So try this:

    os.stat('feedparser.py')[8]

    Compare that with your create date on the file in ls -lah

    They should be the same.

提交回复
热议问题